-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from abcucberkeley/cpp
Cpp
- Loading branch information
Showing
1,849 changed files
with
531,143 additions
and
1,224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
cmake_minimum_required(VERSION 3.9) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE Release) | ||
endif() | ||
|
||
set(CMAKE_CXX_FLAGS "-Wall -Wextra") | ||
set(CMAKE_CXX_FLAGS_DEBUG "-g") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3 -DNDEBUG") | ||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") | ||
|
||
project( | ||
cpp-tiff | ||
VERSION 1.1.0 | ||
LANGUAGES CXX) | ||
|
||
# OpenMP is Required | ||
find_package(OpenMP REQUIRED) | ||
|
||
if(UNIX) | ||
set(ZLIB_STATIC_NAME "libz.a") | ||
else() | ||
set(ZLIB_STATIC_NAME "libzlib.a") | ||
endif() | ||
|
||
set(SKIP_INSTALL_ALL ON CACHE BOOL "" FORCE) | ||
set(ZLIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib-1.2.8") | ||
add_subdirectory(${ZLIB_DIR}) | ||
set_property(TARGET zlibstatic PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
|
||
set(LIBDEFLATE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libdeflate-1.18") | ||
add_subdirectory(${LIBDEFLATE_DIR}) | ||
set_property(TARGET libdeflate_static PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
|
||
set(ZSTD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zstd-1.5.5") | ||
add_subdirectory(${ZSTD_DIR}/build/cmake) | ||
set_property(TARGET libzstd_static PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
|
||
# Add libtiff | ||
include_directories(${ZSTD_DIR}/lib) | ||
set(ZLIB_INCLUDE_DIR ${ZLIB_DIR} CACHE STRING "" FORCE) | ||
set(ZLIB_LIBRARY ${CMAKE_BINARY_DIR}/dependencies/zlib-1.2.8/${ZLIB_STATIC_NAME} CACHE STRING "" FORCE) | ||
set(Deflate_INCLUDE_DIR ${LIBDEFLATE_DIR} CACHE STRING "" FORCE) | ||
set(Deflate_LIBRARY ${CMAKE_BINARY_DIR}/dependencies/libdeflate-1.18/libdeflate.a CACHE STRING "" FORCE) | ||
set(ZSTD_INCLUDE_DIR ${ZSTD_DIR}/lib CACHE STRING "" FORCE) | ||
set(ZSTD_LIBRARY ${CMAKE_BINARY_DIR}/dependencies/zstd-1.5.5/build/cmake/lib/libzstd.a CACHE STRING "" FORCE) | ||
set(LIBTIFF_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/tiff-4.6.0") | ||
set(tiff-tools OFF CACHE BOOL "" FORCE) | ||
set(tiff-tests OFF CACHE BOOL "" FORCE) | ||
set(tiff-contrib OFF CACHE BOOL "" FORCE) | ||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) | ||
# Disable jpeg and lzma until I can add the dependencies | ||
set(jpeg OFF CACHE BOOL "" FORCE) | ||
set(lzma OFF CACHE BOOL "" FORCE) | ||
|
||
|
||
add_subdirectory(${LIBTIFF_DIR}) | ||
set_property(TARGET tiff PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
add_dependencies(tiff zlibstatic) | ||
add_dependencies(tiff libdeflate_static) | ||
add_dependencies(tiff libzstd_static) | ||
|
||
|
||
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") | ||
|
||
add_library(cppTiff_shared SHARED ${SRC_DIR}/helperfunctions.cpp ${SRC_DIR}/lzwencode.cpp ${SRC_DIR}/parallelreadtiff.cpp ${SRC_DIR}/parallelwritetiff.cpp) | ||
set_target_properties(cppTiff_shared PROPERTIES OUTPUT_NAME cppTiff) | ||
add_dependencies(cppTiff_shared zlibstatic) | ||
add_dependencies(cppTiff_shared libdeflate_static) | ||
add_dependencies(cppTiff_shared libzstd_static) | ||
add_dependencies(cppTiff_shared tiff) | ||
|
||
set_target_properties(cppTiff_shared PROPERTIES PUBLIC_HEADER "${ZSTD_DIR}/lib/zstd.h;${SRC_DIR}/helperfunctions.h;${SRC_DIR}/lzwencode.h;${SRC_DIR}/parallelreadtiff.h;${SRC_DIR}/parallelwritetiff.h") | ||
|
||
# Include the header files | ||
target_include_directories(cppTiff_shared PRIVATE | ||
${ZLIB_DIR} | ||
${LIBDEFLATE_DIR} | ||
${ZSTD_DIR}/lib | ||
${LIBTIFF_DIR}/libtiff | ||
) | ||
|
||
# Link against the libraries | ||
target_link_libraries(cppTiff_shared PRIVATE | ||
${CMAKE_BINARY_DIR}/dependencies/tiff-4.6.0/libtiff/libtiff.a | ||
${CMAKE_BINARY_DIR}/dependencies/zlib-1.2.8/${ZLIB_STATIC_NAME} | ||
${CMAKE_BINARY_DIR}/dependencies/libdeflate-1.18/libdeflate.a | ||
${CMAKE_BINARY_DIR}/dependencies/zstd-1.5.5/build/cmake/lib/libzstd.a | ||
-static-libgcc | ||
-static-libstdc++ | ||
OpenMP::OpenMP_CXX | ||
) | ||
|
||
install(TARGETS cppTiff_shared | ||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NOTE: If you want to upgrade libtiff (or use your own version) then change tiff-x.x.x/cmake/ZSTDCodec.cmake to match the one in the current repo for the lines that check for the presence of zstd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
task: | ||
freebsd_instance: | ||
matrix: | ||
- image_family: freebsd-12-3 | ||
- image_family: freebsd-13-0 | ||
install_script: pkg install -y cmake | ||
script: | ||
- cmake -B build -DLIBDEFLATE_BUILD_TESTS=1 | ||
- cmake --build build | ||
- ctest --test-dir build | ||
# Direct compilation without official build system | ||
- cc -O2 -Wall -Werror lib/*.c lib/*/*.c programs/gzip.c programs/prog_util.c programs/tgetopt.c -o libdeflate-gzip |
Oops, something went wrong.