This commit is contained in:
Karol Babioch 2021-01-13 15:50:48 +03:00 committed by GitHub
commit 94f271c4d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 26 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "externals/sanitizers-cmake"]
path = externals/sanitizers-cmake
url = git://github.com/arsenm/sanitizers-cmake.git

View File

@ -73,6 +73,7 @@ set(OPENJPEG_LIBRARY_PROPERTIES
# Path to additional CMake modules
set(CMAKE_MODULE_PATH
${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake
${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/externals/sanitizers-cmake/cmake
${CMAKE_MODULE_PATH})
# --------------------------------------------------------------------------
@ -245,6 +246,10 @@ check_symbol_exists(posix_memalign stdlib.h OPJ_HAVE_POSIX_MEMALIGN)
unset(CMAKE_REQUIRED_DEFINITIONS)
# memalign (obsolete)
check_symbol_exists(memalign malloc.h OPJ_HAVE_MEMALIGN)
# Make sure there is Sanitizer support in CMake
find_package(Sanitizers)
#-----------------------------------------------------------------------------
# Build Library
if(BUILD_JPIP_SERVER)

1
externals/sanitizers-cmake vendored Submodule

@ -0,0 +1 @@
Subproject commit 6947cff3a9c9305eb9c16135dd81da3feb4bf87f

View File

@ -44,6 +44,7 @@ endif()
# Loop over all executables:
foreach(exe opj_decompress opj_compress opj_dump)
add_executable(${exe} ${exe}.c ${common_SRCS})
add_sanitizers(${exe})
if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.12")
target_compile_options(${exe} PRIVATE ${OPENJP2_COMPILE_OPTIONS})
endif()

View File

@ -28,6 +28,7 @@ endif()
# Loop over all executables:
foreach(exe opj_jp3d_compress opj_jp3d_decompress)
add_executable(${exe} ${exe}.c ${common_SRCS})
add_sanitizers(${exe})
target_link_libraries(${exe} openjp3d)
# On unix you need to link to the math library:
if(UNIX)

View File

@ -10,6 +10,7 @@ include_directories(
# Tool to embed metadata into JP2 file
add_executable(opj_jpip_addxml opj_jpip_addxml.c)
add_sanitizers(opj_jpip_addxml)
# Install exe
install(TARGETS opj_jpip_addxml
EXPORT OpenJPEGTargets
@ -23,6 +24,7 @@ if(BUILD_JPIP_SERVER)
# Build executable
add_executable(opj_server ${OPJ_SERVER_SRCS})
add_sanitizers(opj_server)
target_link_libraries(opj_server ${FCGI_LIBRARIES} openjpip_server)
set_property(
TARGET opj_server
@ -49,6 +51,7 @@ set(EXES
)
foreach(exe ${EXES})
add_executable(${exe} ${exe}.c)
add_sanitizers(${exe})
target_link_libraries(${exe} openjpip)
install(TARGETS ${exe}
EXPORT OpenJPEGTargets

View File

@ -37,6 +37,7 @@ foreach(exe decompress compress)
${jpwl_exe}.c
${common_SRCS}
)
add_sanitizers(${jpwl_exe})
set_property(
TARGET ${jpwl_exe}
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL

View File

@ -32,6 +32,7 @@ foreach(exe
${MJ2_SRCS}
${OPENJPEG_SOURCE_DIR}/src/bin/common/color.c
)
add_sanitizers(${exe})
set_property(
TARGET ${exe}
APPEND PROPERTY COMPILE_DEFINITIONS USE_MJ2

View File

@ -26,4 +26,5 @@ set(OPJV_SRCS
${OPENJPEG_SOURCE_DIR}/src/bin/jp2/index.c
)
add_executable(opjviewer ${OPJV_SRCS})
add_sanitizers(opjviewer)
target_link_libraries(opjviewer ${wxWidgets_LIBRARIES} openjpeg)

View File

@ -94,11 +94,14 @@ else()
if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
# Builds both static and dynamic libs
add_library(${OPENJPEG_LIBRARY_NAME} SHARED ${OPENJPEG_SRCS})
add_sanitizers(${OPENJPEG_LIBRARY_NAME})
add_library(openjp2_static STATIC ${OPENJPEG_SRCS})
add_sanitizers(openjp2_static)
set_target_properties(openjp2_static PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME})
set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME} openjp2_static)
else()
add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
add_sanitizers(${OPENJPEG_LIBRARY_NAME})
set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME})
endif()
endif()
@ -135,6 +138,7 @@ if(BUILD_LUTS_GENERATOR)
# internal utility to generate t1_luts.h (part of the jp2 lib)
# no need to install:
add_executable(t1_generate_luts t1_generate_luts.c)
add_sanitizers(t1_generate_luts)
if(UNIX)
target_link_libraries(t1_generate_luts m)
endif()

View File

@ -23,6 +23,7 @@ endif()
# build jp3d lib:
add_library(${OPENJP3D_LIBRARY_NAME} ${OPENJP3D_SRCS})
add_sanitizers(${OPENJP3D_LIBRARY_NAME})
if(UNIX)
target_link_libraries(${OPENJP3D_LIBRARY_NAME} m)
endif()

View File

@ -60,6 +60,7 @@ if(WIN32)
endif()
endif()
add_library(openjpip ${OPENJPIP_SRCS} ${LOCAL_SRCS})
add_sanitizers(openjpip)
set_target_properties(openjpip
PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.12")
@ -81,6 +82,7 @@ install(TARGETS openjpip
if(BUILD_JPIP_SERVER)
add_library(openjpip_server STATIC ${OPENJPIP_SRCS} ${SERVER_SRCS})
add_sanitizers(openjpip_server)
target_link_libraries(openjpip_server ${FCGI_LIBRARIES} ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
set_target_properties(openjpip_server
PROPERTIES COMPILE_FLAGS "-DSERVER")

View File

@ -46,6 +46,7 @@ if(WIN32)
endif()
endif()
add_library(openjpwl ${JPWL_SRCS} ${OPENJPEG_SRCS})
add_sanitizers(openjpwl)
if(UNIX)
target_link_libraries(openjpwl m)
endif()

View File

@ -40,6 +40,7 @@ endif()
# build mj2 lib:
add_library(${OPENMJ2_LIBRARY_NAME} ${OPENMJ2_SRCS})
add_sanitizers(${OPENMJ2_LIBRARY_NAME})
# FIXME: We are using an openjpeg 1.5 copy:
#target_link_libraries(${OPENMJ2_LIBRARY_NAME} openjp2)
if(UNIX)