Skip to content

Commit

Permalink
Merge 7289e5a into d0ffe60
Browse files Browse the repository at this point in the history
  • Loading branch information
aperezdc authored Oct 24, 2018
2 parents d0ffe60 + 7289e5a commit 86e54fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
42 changes: 14 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 2.8.6)

project(brotli C)

option(BUILD_SHARED_LIBS "Build shared libraries" ON)

# If Brotli is being bundled in another project, we don't want to
# install anything. However, we want to let people override this, so
# we'll use the BROTLI_BUNDLED_MODE variable to let them do that; just
Expand Down Expand Up @@ -114,10 +116,6 @@ set(BROTLI_LIBRARIES_CORE brotlienc brotlidec brotlicommon)
set(BROTLI_LIBRARIES ${BROTLI_LIBRARIES_CORE} ${LIBM_LIBRARY})
mark_as_advanced(BROTLI_LIBRARIES)

set(BROTLI_LIBRARIES_CORE_STATIC brotlienc-static brotlidec-static brotlicommon-static)
set(BROTLI_LIBRARIES_STATIC ${BROTLI_LIBRARIES_CORE_STATIC} ${LIBM_LIBRARY})
mark_as_advanced(BROTLI_LIBRARIES_STATIC)

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_definitions(-DOS_LINUX)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
Expand All @@ -137,24 +135,22 @@ endfunction()
transform_sources_list("scripts/sources.lst" "${CMAKE_CURRENT_BINARY_DIR}/sources.lst.cmake")
include("${CMAKE_CURRENT_BINARY_DIR}/sources.lst.cmake")

add_library(brotlicommon SHARED ${BROTLI_COMMON_C})
add_library(brotlidec SHARED ${BROTLI_DEC_C})
add_library(brotlienc SHARED ${BROTLI_ENC_C})

add_library(brotlicommon-static STATIC ${BROTLI_COMMON_C})
add_library(brotlidec-static STATIC ${BROTLI_DEC_C})
add_library(brotlienc-static STATIC ${BROTLI_ENC_C})
add_library(brotlicommon ${BROTLI_COMMON_C})
add_library(brotlidec ${BROTLI_DEC_C})
add_library(brotlienc ${BROTLI_ENC_C})

# Older CMake versions does not understand INCLUDE_DIRECTORIES property.
include_directories(${BROTLI_INCLUDE_DIRS})

foreach(lib brotlicommon brotlidec brotlienc)
target_compile_definitions(${lib} PUBLIC "BROTLI_SHARED_COMPILATION" )
string(TOUPPER "${lib}" LIB)
set_target_properties (${lib} PROPERTIES DEFINE_SYMBOL "${LIB}_SHARED_COMPILATION" )
endforeach()
if(BUILD_SHARED_LIBS)
foreach(lib brotlicommon brotlidec brotlienc)
target_compile_definitions(${lib} PUBLIC "BROTLI_SHARED_COMPILATION" )
string(TOUPPER "${lib}" LIB)
set_target_properties (${lib} PROPERTIES DEFINE_SYMBOL "${LIB}_SHARED_COMPILATION" )
endforeach()
endif()

foreach(lib brotlicommon brotlidec brotlienc brotlicommon-static brotlidec-static brotlienc-static)
foreach(lib brotlicommon brotlidec brotlienc)
target_link_libraries(${lib} ${LIBM_LIBRARY})
set_property(TARGET ${lib} APPEND PROPERTY INCLUDE_DIRECTORIES ${BROTLI_INCLUDE_DIRS})
set_target_properties(${lib} PROPERTIES
Expand All @@ -167,9 +163,6 @@ endforeach()
target_link_libraries(brotlidec brotlicommon)
target_link_libraries(brotlienc brotlicommon)

target_link_libraries(brotlidec-static brotlicommon-static)
target_link_libraries(brotlienc-static brotlicommon-static)

# For projects stuck on older versions of CMake, this will set the
# BROTLI_INCLUDE_DIRS and BROTLI_LIBRARIES variables so they still
# have a relatively easy way to use Brotli:
Expand All @@ -183,7 +176,7 @@ endif()

# Build the brotli executable
add_executable(brotli ${BROTLI_CLI_C})
target_link_libraries(brotli ${BROTLI_LIBRARIES_STATIC})
target_link_libraries(brotli ${BROTLI_LIBRARIES})

# Installation
if(NOT BROTLI_BUNDLED_MODE)
Expand All @@ -199,13 +192,6 @@ if(NOT BROTLI_BUNDLED_MODE)
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)

install(
TARGETS ${BROTLI_LIBRARIES_CORE_STATIC}
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)

install(
DIRECTORY ${BROTLI_INCLUDE_DIRS}/brotli
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
Expand Down
6 changes: 3 additions & 3 deletions c/fuzz/test_fuzzer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ mkdir bin
cd bin

cmake $BROTLI -DCMAKE_C_COMPILER="$CC" \
-DBUILD_TESTING=OFF -DENABLE_SANITIZER=address
make -j$(nproc) brotlidec-static
-DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_SANITIZER=address
make -j$(nproc) brotlidec

${CC} -o run_decode_fuzzer -std=c99 -fsanitize=address -I$SRC/include \
$SRC/fuzz/decode_fuzzer.c $SRC/fuzz/run_decode_fuzzer.c \
./libbrotlidec-static.a ./libbrotlicommon-static.a
./libbrotlidec.a ./libbrotlicommon.a

mkdir decode_corpora
unzip $BROTLI/java/org/brotli/integration/fuzz_data.zip -d decode_corpora
Expand Down

0 comments on commit 86e54fc

Please sign in to comment.