Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

use cmake modules for superlu and lzo. use pkg-config for usb, glew and lz4(not static). (WIP) fixed getting kinda hack for tiff out to libtiff

roentgen19af1bad0455
diff --git a/toonz/sources/CMakeLists.txt b/toonz/sources/CMakeLists.txt
index 959632214..b143013d4 100644
--- a/toonz/sources/CMakeLists.txt
+++ b/toonz/sources/CMakeLists.txt
@@ -3,6 +3,14 @@ project(OpenToonz)
get_filename_component(SDKROOT ../../thirdparty/ ABSOLUTE)
message("SDK Root:" ${SDKROOT})
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "../cmake")
+if(APPLE)
+ set(THIRDPARTY_LIBS_HINTS "/usr/local/Cellar/" "/opt/include" ${SDKROOT})
+elseif(WIN32)
+ set(THIRDPARTY_LIBS_HINTS ${SDKROOT})
+endif()
+
+message("Thirdpary Library Search path:" ${THIRDPARTY_LIBS_HINTS})
if (WIN32)
message("Windows System")
@@ -22,7 +30,9 @@ elseif (APPLE)
if (PLATFORM EQUAL 64)
set(QT_PATH "~/Qt/5.5/clang_64/lib/")
set(QT_LIB_PATH ${QT_PATH})
- set(CMAKE_PREFIX_PATH ${QT_PATH}cmake/)
+ set(CMAKE_PREFIX_PATH "${QT_PATH}cmake/")
+
+
message("CMAKE_PREFIX_PATH:" ${CMAKE_PREFIX_PATH})
add_definitions(-DMACOSX -Di386)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -std=c++11 -stdlib=libc++ -fno-implicit-templates")
@@ -51,6 +61,8 @@ set(CMAKE_INSTALL_RPATH ${QT_LIB_PATH})
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+include_directories(include)
+
# Find the QtWidgets library
find_package(Qt5 REQUIRED
Core
@@ -64,8 +76,6 @@ find_package(Qt5 REQUIRED
PrintSupport
LinguistTools)
-include_directories(include ${SDKROOT}/boost/boost_1_55_0/)
-
if(WIN32)
include_directories(
${SDKROOT}/glut/3.7.6/include
@@ -126,18 +136,51 @@ else()
find_library(GLUT_LIB GLUT)
find_library(GL_LIB OpenGL)
find_library(Z_LIB z)
- set(JPEG_LIB ${SDKROOT}/LibJPEG/jpeg-9/libjpeg.a)
- set(TIFF_LIB ${SDKROOT}/LibTIFF/tiff-4.0.3/lib/libtiff.a)
- set(GLEW_LIB ${SDKROOT}/glew/glew-1.9.0/lib/libGLEW.dylib)
- set(LZ4_LIB ${SDKROOT}/Lz4/Lz4_131/lib/liblz4.a)
- set(SUPERLU_LIB ${SDKROOT}/superlu/libsuperlu_4.1.a)
+ find_library(TIFF_LIB TIFF)
+
+ # the libraries have not .pc nor preferred Find*.cmake. use custom modules.
+ find_package(GLEW)
+
+ find_package(SuperLU REQUIRED)
+ set(SUPERLU_INCLUDE_DIR ${SUPERLU_INCLUDE_DIR}/superlu)
+ set(SUPERLU_LIB ${SUPERLU_LIBRARY})
+ message("SuperLU:" ${SUPERLU_INCLUDE_DIR})
+
+ find_package(LZO REQUIRED)
+ message("LZO:" ${LZO_INCLUDE_DIR})
+
+ find_package(JPEG REQUIRED)
+
+ # the libraries have .pc
+ find_package(PkgConfig)
+ if(GLEW-NOTFOUND)
+ pkg_check_modules(GLEW REQUIRED glew)
+ endif()
+ set(GLEW_LIB ${GLEW_LIBRARIES})
+
+ pkg_check_modules(LZ4_LIB REQUIRED liblz4)
+
+ message("**************** lz4 lib:" ${LZ4_LIB_INCLUDE_DIRS})
+ find_path(LZ4_STATIC lz4frame_static.h PATH ${LZ4_LIB_INCLUDE_DIRS})
+ if(LZ4_STATIC-FOUND)
+ add_definitions(-DLZ4_STATIC)
+ endif()
+
+ pkg_check_modules(USB_LIB REQUIRED libusb-1.0)
set(OPENBLAS_LIB) # unused?
- set(USB_LIB ${SDKROOT}/libusb/libusb-1.0.9/libusb/.libs/libusb-1.0.a)
if (PLATFORM EQUAL 32)
find_library(QT_LIB QuickTime)
endif()
+
+ set(JPEG_LIB ${JPEG_LIBRARY})
+ set(LZ4_LIB ${LZ4_LIB_LDFLAGS})
endif()
+find_path(BOOST_ROOT include/boost HINTS ${THIRDPARTY_LIBS_HINTS} PATH_SUFFIXES boost155/1.55.0_1 boost/boost_1_55_0/)
+find_package(Boost 1.55 EXACT REQUIRED)
+
+include_directories(${Boost_INCLUDE_DIR} ${LZ4_LIB_INCLUDE_DIRS} ${USB_LIB_INCLUDE_DIRS} ${SUPERLU_INCLUDE_DIR} ${JPEG_INCLUDE_DIR})
+
if(WIN32 AND PLATFORM EQUAL 64)
add_definitions(-Dx64)
endif()
@@ -180,7 +223,11 @@ add_subdirectory(toonzqt)
add_subdirectory(tnztools)
add_subdirectory(toonz)
-add_subdirectory(${SDKROOT}/lzo/driver lzodriver)
+find_path(LZODRIVER lzodriver HINTS ${THIRDPARTY_LIBS_HINTS})
+if(LZODRIVER-FOUND)
+ set(LZODRIVER-FOUND true)
+ add_subdirectory(${SDKROOT}/lzo/driver lzodriver)
+endif()
add_subdirectory(tcleanupper)
add_subdirectory(tcomposer)
diff --git a/toonz/sources/common/trasterimage/tcodec.cpp b/toonz/sources/common/trasterimage/tcodec.cpp
index 3d32c7b36..437a583b9 100644
--- a/toonz/sources/common/trasterimage/tcodec.cpp
+++ b/toonz/sources/common/trasterimage/tcodec.cpp
@@ -10,7 +10,12 @@
#include "trasterimage.h"
//#include "snappy-c.h"
+#if defined(LZ4_STATIC)
#include "lz4frame_static.h"
+#else
+#include "lz4frame.h"
+#endif
+
#include <QDir>
#include <QProcess>
#include <QCoreApplication>
diff --git a/toonz/sources/common/tstream/tstream.cpp b/toonz/sources/common/tstream/tstream.cpp
index 985086b47..8e48833c8 100644
--- a/toonz/sources/common/tstream/tstream.cpp
+++ b/toonz/sources/common/tstream/tstream.cpp
@@ -7,7 +7,11 @@
#include "tsystem.h"
#include "tutil.h"
+#if defined(LZ4_STATIC)
#include "lz4frame_static.h"
+#else
+#include "lz4frame.h"
+#endif
#include <sstream>
diff --git a/toonz/sources/image/tif/tif_getimage_64.h b/toonz/sources/image/tif/tif_getimage_64.h
index f0f1ac042..506b35b10 100644
--- a/toonz/sources/image/tif/tif_getimage_64.h
+++ b/toonz/sources/image/tif/tif_getimage_64.h
@@ -4,6 +4,8 @@
#include "tiff.h"
#include "tiffio.h"
+#include <stdint.h>
+typedef uint64_t uint64;
/* \file libtiff_64.h
@@ -21,4 +23,4 @@ int TIFFRGBAImageGet_64(TIFFRGBAImage *img, uint64 *raster, uint32 w, uint32 h);
int TIFFReadRGBAStrip_64(TIFF *tif, uint32 row, uint64 *raster);
int TIFFReadRGBATile_64(TIFF *tif, uint32 x, uint32 y, uint64 *raster);
-#endif // LIBTIFF_64_H
\ No newline at end of file
+#endif // LIBTIFF_64_H
diff --git a/toonz/sources/image/tif/tiio_tif.cpp b/toonz/sources/image/tif/tiio_tif.cpp
index 6b40d9719..5167ff39d 100644
--- a/toonz/sources/image/tif/tiio_tif.cpp
+++ b/toonz/sources/image/tif/tiio_tif.cpp
@@ -5,6 +5,8 @@
#endif
#define IS_TIFF_MAIN
+#include <unistd.h>
+
#include "tiio.h"
#include "tpixel.h"
#include "tsystem.h"
@@ -92,7 +94,11 @@ TifReader::~TifReader()
void TifReader::open(FILE *file)
{
int fd = fileno(file);
+#if 0
m_tiff = TIFFFdOpenNoCloseProc(fd, "", "rb");
+#else
+ m_tiff = TIFFFdOpen(dup(fd), "", "rb");
+#endif
if (!m_tiff) {
string str("Tiff file closed");
throw(str);
@@ -772,7 +778,11 @@ void TifWriter::open(FILE *file, const TImageInfo &info)
assert(m_bpp == 1 || m_bpp == 8 || m_bpp == 16 || m_bpp == 24 || m_bpp == 32 || m_bpp == 48 || m_bpp == 64);
int fd = fileno(file);
+#if 0
m_tiff = TIFFFdOpenNoCloseProc(fd, "", mode.c_str());
+#else
+ m_tiff = TIFFFdOpen(dup(fd), "", mode.c_str());
+#endif
if (!m_tiff)
return;
diff --git a/toonz/sources/stdfx/CMakeLists.txt b/toonz/sources/stdfx/CMakeLists.txt
index 4ff3c43be..f483c1023 100644
--- a/toonz/sources/stdfx/CMakeLists.txt
+++ b/toonz/sources/stdfx/CMakeLists.txt
@@ -253,11 +253,22 @@ endif (APPLE)
message("subdir: tnzstdfx")
message("Bin: " ${CMAKE_CURRENT_BINARY_DIR})
-include_directories(${SDKROOT}/glew/glew-1.9.0/include)
+if(GLEW_FOUND)
+ include_directories(${GLEW_INCLUDE_DIRS})
+else()
+ include_directories(${SDKROOT}/glew/glew-1.9.0/include)
+endif()
+
_find_toonz_library(TNZLIBS "tnzcore;tnzbase;toonzlib")
if (APPLE)
- find_library(ICONV_LIB iconv)
+ # macports を使っていると symbol が非互換の /opt/lib が引っ掛かってしまう
+ find_library(ICONV_LIB iconv HINTS /usr/lib)
+ if(ICONV_LIB-NOTFOUND)
+ message("************* NO ICONV ****************")
+ else()
+ message("************* ICONV:" ${ICONV_LIB})
+ endif()
target_link_libraries(tnzstdfx Qt5::Core Qt5::Gui Qt5::OpenGL ${GL_LIB} ${GLEW_LIB} ${TNZLIBS} ${ICONV_LIB})
else ()
target_link_libraries(tnzstdfx Qt5::Core Qt5::Gui Qt5::OpenGL ${GL_LIB} ${GLEW_LIB} ${TNZLIBS})
diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txt
index 3f6680f11..9916b8aab 100644
--- a/toonz/sources/toonz/CMakeLists.txt
+++ b/toonz/sources/toonz/CMakeLists.txt
@@ -376,8 +376,10 @@ if (APPLE)
endif()
# copy utilty executables onto the directory after build
-add_custom_command(TARGET OpenToonz_${VERSION} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:lzocompress> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS lzocompress)
-add_custom_command(TARGET OpenToonz_${VERSION} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:lzodecompress> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS lzodecompress)
+if(LZODRIVER-FOUND)
+ add_custom_command(TARGET OpenToonz_${VERSION} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:lzocompress> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS lzocompress)
+ add_custom_command(TARGET OpenToonz_${VERSION} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:lzodecompress> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS lzodecompress)
+endif()
if (APPLE)
get_target_property(loc OpenToonz_${VERSION} MACOSX_BUNDLE_NAME)