Skip to content

Commit

Permalink
Version v1.0.0 bump
Browse files Browse the repository at this point in the history
  • Loading branch information
minknowbot committed Jul 25, 2019
1 parent 63efdcc commit 2db0e3f
Show file tree
Hide file tree
Showing 83 changed files with 2,573 additions and 524 deletions.
152 changes: 124 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ project(hdf_plugins
LANGUAGES CXX
)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

include(ExternalProject)
include(GenerateExportHeader)
Expand All @@ -33,9 +31,34 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "${_bt_docstring}" FORCE)
endif()

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

if (NOT DEFINED VBZ_BUILD_ARCHIVE)
option(VBZ_BUILD_ARCHIVE "Build vbz release as an single archive" OFF)
endif()

if (NOT DEFINED ENABLE_PYTHON)
option(ENABLE_PYTHON "Build python wheel" ON)
endif()

if (NOT DEFINED ENABLE_PACKAGING)
option(ENABLE_PACKAGING "Enable packaging support" ON)
endif()

if (NOT DEFINED ENABLE_PERF_TESTING)
option(ENABLE_PERF_TESTING "Enable performance tests" ON)
endif()

if (NOT DEFINED ENABLE_CONAN)
option(ENABLE_CONAN "Enable conan for dependency installation" ON)
endif()

if (NOT VBZ_BUILD_ARCHIVE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()

option(ENABLE_CONAN "Enable conan for dependency installation" ON)
if (ENABLE_CONAN)
#
# Dependencies: Conan
Expand All @@ -62,49 +85,122 @@ if (ENABLE_CONAN)

conan_cmake_run(CONANFILE conanfile.txt ${_extra_args})
endif()
# Don't use conan_basic_setup() - half of what it does conflicts with or duplicates ONTSettings.
# TODO: revisit this decision: it could be good to force the flags to match how depenencies were
# built. Might also be useful for anything using MinKNOW-Core code (eg: VolTRAX).
conan_check_compiler()
#conan_set_find_library_paths()
conan_define_targets()
conan_set_find_paths()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Linking conan debug libraries")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CONAN_CMAKE_MODULE_PATH_DEBUG})
else()
message(STATUS "Linking conan release libraries")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CONAN_CMAKE_MODULE_PATH_RELEASE})
endif()
endif()

include(packaging/hdf_plugin_packaging.cmake)
if (ENABLE_PACKAGING)
include(packaging/hdf_plugin_packaging.cmake)
endif()

include_directories("${CMAKE_SOURCE_DIR}/third_party")

find_package(HDF5 1.8.16)
find_package(zstd 1.3.4 REQUIRED)
find_package(zstd 1.3.3 REQUIRED)
find_package(Sanitizers)

get_filename_component(STREAMVBYTE_SOURCE_DIR
third_party/streamvbyte
ABSOLUTE
)
set(STREAMVBYTE_INSTALL_DIR "${CMAKE_BINARY_DIR}/streamvbyte_lib/")
set(STREAMVBYTE_PREFIX ${CMAKE_BINARY_DIR}/streamvbyte)
set(STREAMVBYTE_STATIC_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}streamvbyte_static${CMAKE_STATIC_LIBRARY_SUFFIX})
set(STREAMVBYTE_STATIC_LIB_SUBDIR ".")
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (is_multi_config)
set(STREAMVBYTE_STATIC_LIB_SUBDIR "$<CONFIG>")
endif()
ExternalProject_Add(
streamvbyte
SOURCE_DIR ${STREAMVBYTE_SOURCE_DIR}
UPDATE_DISCONNECTED TRUE
PREFIX ${CMAKE_BINARY_DIR}/streamvbyte
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${STREAMVBYTE_INSTALL_DIR}
PREFIX ${STREAMVBYTE_PREFIX}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${STREAMVBYTE_INSTALL_DIR} -DSTREAMVBYTE_DISABLE_NATIVE=ON
# We need to tell CMake about libraries we will link to, otherwise some generators (eg: Ninja)
# complain about how knowing how to build libstreamvbyte_static.a, for example.
# Ideally, we'd set a hypothetical INSTALL_BYPRODUCTS, and link to the installed file, but that
# doesn't seem to be an option.
BUILD_BYPRODUCTS "<BINARY_DIR>/${STREAMVBYTE_STATIC_LIB_NAME}"
)
if (NOT WIN32)
set(STREAMVBYTE_STATIC_LIB ${STREAMVBYTE_INSTALL_DIR}/lib/libstreamvbyte_static.a)
else()
set(STREAMVBYTE_STATIC_LIB ${STREAMVBYTE_INSTALL_DIR}/lib/streamvbyte_static.lib)
ExternalProject_Get_Property(streamvbyte BINARY_DIR)
set(STREAMVBYTE_STATIC_LIB "${BINARY_DIR}/${STREAMVBYTE_STATIC_LIB_SUBDIR}/${STREAMVBYTE_STATIC_LIB_NAME}")


########################################################################
#
# Warnings
#
########################################################################

if (MSVC)
add_compile_options(
# Level 3 warnings, as errors
/W3 /WX

##
## Disable warnings:
##

# C4251: A base class or structure must be declared with the __declspec(dllexport) keyword
# for a function in a derived class to be exported.
#
# Happens when using STL types as members of a class tagged with WHATEVER_EXPORT. Since we
# don't care about our DLLs maintaining compatibility with other versions of the CRT
# (Microsoft's C Runtime Library), this is just noise.
/wd4251

# C4275: An exported class was derived from a class that was not exported.
#
# Very similar to C4251, but for inheritance rather than members. Again, just noise for us.
/wd4275

# C4373: '%$S': virtual function overrides '%$pS', previous versions of the compiler did not
# override when parameters only differed by const/volatile qualifiers
#
# The current behaviour (virtuals are overridden when their arguments differ only in
# constness) is what you'd expect - the warning only exists because VS 2008 and earlier had
# *different* behaviour. Since we never used VS 2008, this warning isn't useful to us.
/wd4373

##
## Enable additional warnings:
##

# C5038: data member 'member1' will be initialized after data member 'member2'
#
# Enable warning about incorrect order of initialisation in classes.
# Matches clang warnings which are enabled on the build server.
/w35038
)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
# MSVC's standard library warns about a lot of "insecure" code by default (eg: unchecked
# iterators). However, the recommended replacements are not cross-platform, so aren't really
# an option for us.
_SCL_SECURE_NO_WARNINGS
)
elseif (CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(
# "All" warnings as errors
-Wall -Wextra -Werror

# Unused parameters are too common (and unimportant) to warn about
-Wno-unused-parameter
# Missing field init warning is too general to be useful in C++ code
-Wno-missing-field-initializers
# boost::optional triggers this on release builds
-Wno-maybe-uninitialized
)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # AppleClang and Clang
add_compile_options(
# "All" warnings as errors
-Wall -Werror
)
endif()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_subdirectory(python)
if (ENABLE_PYTHON)
add_subdirectory(python)
endif()
add_subdirectory(vbz)
add_subdirectory(vbz_plugin)
add_subdirectory(vbz_plugin)
59 changes: 59 additions & 0 deletions cmake/FindASan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# The MIT License (MIT)
#
# Copyright (c)
# 2013 Matthew Arsenault
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

option(SANITIZE_ADDRESS "Enable AddressSanitizer for sanitized targets." Off)

set(FLAG_CANDIDATES
# Clang 3.2+ use this version. The no-omit-frame-pointer option is optional.
"-g -fsanitize=address -fno-omit-frame-pointer"
"-g -fsanitize=address"

# Older deprecated flag for ASan
"-g -faddress-sanitizer"
)


if (SANITIZE_ADDRESS AND (SANITIZE_THREAD OR SANITIZE_MEMORY))
message(FATAL_ERROR "AddressSanitizer is not compatible with "
"ThreadSanitizer or MemorySanitizer.")
endif ()


include(sanitize-helpers)

if (SANITIZE_ADDRESS)
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "AddressSanitizer"
"ASan")

find_program(ASan_WRAPPER "asan-wrapper" PATHS ${CMAKE_MODULE_PATH})
mark_as_advanced(ASan_WRAPPER)
endif ()

function (add_sanitize_address TARGET)
if (NOT SANITIZE_ADDRESS)
return()
endif ()

sanitizer_add_flags(${TARGET} "AddressSanitizer" "ASan")
endfunction ()
28 changes: 28 additions & 0 deletions cmake/FindFuzzer.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

option(SANITIZE_FUZZER "Enable Fuzzer for sanitized targets." Off)

include(sanitize-helpers)

if (SANITIZE_FUZZER)
set(CMAKE_REQUIRED_FLAGS "-g -fsanitize=fuzzer")
check_cxx_source_compiles("#include <cstdint>\n#include <cstddef>\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {}" Fuzz_FLAG_DETECTED)

get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
foreach (LANG ${ENABLED_LANGUAGES})
# Sanitizer flags are not dependend on language, but the used compiler.
# So instead of searching flags foreach language, search flags foreach
# compiler used.
set(COMPILER ${CMAKE_${LANG}_COMPILER_ID})
if (Fuzz_FLAG_DETECTED)
set(Fuzz_${COMPILER}_FLAGS "${CMAKE_REQUIRED_FLAGS}" CACHE STRING "Fuzzer arguments")
endif()
endforeach()
endif()

function(add_sanitize_fuzzer TARGET)
if (NOT SANITIZE_FUZZER)
return()
endif ()

sanitizer_add_flags(${TARGET} "FuzzSanitizer" "Fuzz")
endfunction ()
13 changes: 10 additions & 3 deletions cmake/FindGoogleBenchmark.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@

find_path(GOOGLE_BENCHMARK_INCLUDE_DIR
NAMES benchmark/benchmark.h
PATHS ${CONAN_INCLUDE_DIRS_RELEASE}
)

set(GOOGLE_BENCHMARK benchmark)
set(GOOGLE_BENCHMARK_DEBUG benchmarkd)

find_library(GOOGLE_BENCHMARK_LIBRARY_RELEASE NAMES ${GOOGLE_BENCHMARK})
find_library(GOOGLE_BENCHMARK_LIBRARY_DEBUG NAMES ${GOOGLE_BENCHMARK_DEBUG})
find_library(GOOGLE_BENCHMARK_LIBRARY_RELEASE
NAMES ${GOOGLE_BENCHMARK}
PATHS ${CONAN_LIB_DIRS_RELEASE}
)
find_library(GOOGLE_BENCHMARK_LIBRARY_DEBUG
NAMES ${GOOGLE_BENCHMARK_DEBUG}
PATHS ${CONAN_LIB_DIRS_DEBUG}
)

include(SelectLibraryConfigurations)
select_library_configurations(GOOGLE_BENCHMARK)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GOOGLE_BENCHMARK REQUIRED_VARS GOOGLE_BENCHMARK_LIBRARY GOOGLE_BENCHMARK_INCLUDE_DIR)
find_package_handle_standard_args(google-benchmark REQUIRED_VARS GOOGLE_BENCHMARK_LIBRARY GOOGLE_BENCHMARK_INCLUDE_DIR)


if (GOOGLE_BENCHMARK_FOUND)
Expand Down
57 changes: 57 additions & 0 deletions cmake/FindMSan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# The MIT License (MIT)
#
# Copyright (c)
# 2013 Matthew Arsenault
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

option(SANITIZE_MEMORY "Enable MemorySanitizer for sanitized targets." Off)

set(FLAG_CANDIDATES
"-g -fsanitize=memory"
)


include(sanitize-helpers)

if (SANITIZE_MEMORY)
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
message(WARNING "MemorySanitizer disabled for target ${TARGET} because "
"MemorySanitizer is supported for Linux systems only.")
set(SANITIZE_MEMORY Off CACHE BOOL
"Enable MemorySanitizer for sanitized targets." FORCE)
elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8)
message(WARNING "MemorySanitizer disabled for target ${TARGET} because "
"MemorySanitizer is supported for 64bit systems only.")
set(SANITIZE_MEMORY Off CACHE BOOL
"Enable MemorySanitizer for sanitized targets." FORCE)
else ()
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "MemorySanitizer"
"MSan")
endif ()
endif ()

function (add_sanitize_memory TARGET)
if (NOT SANITIZE_MEMORY)
return()
endif ()

sanitizer_add_flags(${TARGET} "MemorySanitizer" "MSan")
endfunction ()
Loading

0 comments on commit 2db0e3f

Please sign in to comment.