Toshihiro Shimizu 890ddd
cmake_minimum_required(VERSION 2.8.11)
Toshihiro Shimizu 890ddd
project(OpenToonz)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
get_filename_component(SDKROOT ../../thirdparty/ ABSOLUTE)
Toshihiro Shimizu 890ddd
message("SDK Root:" ${SDKROOT})
roentgen 19af1b
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "../cmake")
roentgen 19af1b
if(APPLE)
roentgen 19af1b
    set(THIRDPARTY_LIBS_HINTS "/usr/local/Cellar/" "/opt/include" ${SDKROOT})
roentgen 19af1b
elseif(WIN32)
roentgen 19af1b
    set(THIRDPARTY_LIBS_HINTS ${SDKROOT})
roentgen 19af1b
endif()
roentgen 19af1b
roentgen 19af1b
message("Thirdpary Library Search path:" ${THIRDPARTY_LIBS_HINTS})
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
if (WIN32)
Toshihiro Shimizu 890ddd
    message("Windows System")
Toshihiro Shimizu 890ddd
    set(QT_PATH "C:/Qt/Qt5.5.1/5.5/msvc2013_64" CACHE PATH "Qt instlattion directory")
Toshihiro Shimizu 890ddd
    if(NOT EXISTS ${QT_PATH})
Toshihiro Shimizu 890ddd
        message("Specify QT_PATH properly")
Toshihiro Shimizu 890ddd
        return()
Toshihiro Shimizu 890ddd
    endif()
Toshihiro Shimizu 890ddd
    set(QT_LIB_PATH ${QT_PATH})
Toshihiro Shimizu 890ddd
    set(CMAKE_PREFIX_PATH "${QT_PATH}/lib/cmake/")
Toshihiro Shimizu 890ddd
elseif (APPLE)
Toshihiro Shimizu 890ddd
    message("Apple System")
Toshihiro Shimizu 890ddd
    if (NOT PLATFORM)
Toshihiro Shimizu 890ddd
        set(PLATFORM 64)
Toshihiro Shimizu 890ddd
    endif()
Toshihiro Shimizu 890ddd
    message("PLATFORM:" ${PLATFORM})
Toshihiro Shimizu 890ddd
    if (PLATFORM EQUAL 64)
Toshihiro Shimizu 890ddd
        set(QT_PATH "~/Qt/5.5/clang_64/lib/")
Toshihiro Shimizu 890ddd
        set(QT_LIB_PATH ${QT_PATH})
roentgen 19af1b
        set(CMAKE_PREFIX_PATH "${QT_PATH}cmake/")
roentgen 19af1b
roentgen 19af1b
Toshihiro Shimizu 890ddd
        message("CMAKE_PREFIX_PATH:" ${CMAKE_PREFIX_PATH})
Toshihiro Shimizu 890ddd
        add_definitions(-DMACOSX -Di386)
Toshihiro Shimizu 890ddd
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -std=c++11 -stdlib=libc++ -fno-implicit-templates")
Toshihiro Shimizu 890ddd
    elseif(PLATFORM EQUAL 32)
Toshihiro Shimizu 890ddd
        set(QT_PATH "~/Qt/5.5/clang_32/lib/")
Toshihiro Shimizu 890ddd
        set(QT_LIB_PATH ${QT_PATH})
Toshihiro Shimizu 890ddd
        set(CMAKE_PREFIX_PATH ${QT_PATH}cmake/)
Toshihiro Shimizu 890ddd
        message("CMAKE_PREFIX_PATH:" ${CMAKE_PREFIX_PATH})
Toshihiro Shimizu 890ddd
        add_definitions(-DMACOSX -Di386)
Toshihiro Shimizu 890ddd
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -std=c++11 -stdlib=libc++ -fno-implicit-templates -D HAS_QUICKDRAW")
Toshihiro Shimizu 890ddd
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
Toshihiro Shimizu 890ddd
        set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -m32")
Toshihiro Shimizu 890ddd
    else()
Toshihiro Shimizu 890ddd
        message(FATAL_ERROR "Invalid PLATFORM:" ${PLATFORM} ". 'PLATFORM' must be 32 or 64.")
Toshihiro Shimizu 890ddd
    endif()
Toshihiro Shimizu 890ddd
else ()
Toshihiro Shimizu 890ddd
    message("Unknown System")
Toshihiro Shimizu 890ddd
endif ()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
add_definitions(-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
# Find includes in corresponding build directories
Toshihiro Shimizu 890ddd
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
set(CMAKE_INSTALL_RPATH ${QT_LIB_PATH})
Toshihiro Shimizu 890ddd
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
Toshihiro Shimizu 890ddd
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 
Toshihiro Shimizu 890ddd
roentgen 19af1b
include_directories(include)
roentgen 19af1b
Toshihiro Shimizu 890ddd
# Find the QtWidgets library
Toshihiro Shimizu 890ddd
find_package(Qt5 REQUIRED
Toshihiro Shimizu 890ddd
    Core
Toshihiro Shimizu 890ddd
    Gui
Toshihiro Shimizu 890ddd
    Network
Toshihiro Shimizu 890ddd
    OpenGL
Toshihiro Shimizu 890ddd
    Svg
Toshihiro Shimizu 890ddd
    Xml
Toshihiro Shimizu 890ddd
    Script
Toshihiro Shimizu 890ddd
    Widgets
Toshihiro Shimizu 890ddd
    PrintSupport
Toshihiro Shimizu 890ddd
    LinguistTools)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
if(WIN32)
Toshihiro Shimizu 890ddd
    include_directories(
Toshihiro Shimizu 890ddd
        ${SDKROOT}/glut/3.7.6/include
Toshihiro Shimizu 890ddd
        ${SDKROOT}/zlib/zlib-1.2.7
Toshihiro Shimizu 890ddd
        ${SDKROOT}/LibJPEG/jpeg-9)
Toshihiro Shimizu 890ddd
    add_definitions(-DGLUT_NO_LIB_PRAGMA)
Toshihiro Shimizu 890ddd
endif()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
get_target_property(QtCore_location Qt5::Core LOCATION)
Toshihiro Shimizu 890ddd
get_target_property(QtWidget_location Qt5::Widgets LOCATION)
Toshihiro Shimizu 890ddd
message("Qt Core Location:" ${QtCore_location})
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
macro(_find_toonz_library OUT_LIB_LIST IN_LIB_LIST)
Toshihiro Shimizu 890ddd
    set(OUTLIST "")
Toshihiro Shimizu 890ddd
    foreach(arg ${IN_LIB_LIST})
Toshihiro Shimizu 890ddd
        unset(COREPATH CACHE)
Toshihiro Shimizu 890ddd
        # find しても cmake が走るときにはできていないので完全なパス名を生成して返すだけ
Toshihiro Shimizu 890ddd
        if(WIN32)
Toshihiro Shimizu 890ddd
            set(LIBPATH ${arg})
Toshihiro Shimizu 890ddd
        else()
Toshihiro Shimizu 890ddd
            set(LIBPATH ${CMAKE_CURRENT_BINARY_DIR}/../${arg}/lib${arg}${CMAKE_SHARED_LIBRARY_SUFFIX})
Toshihiro Shimizu 890ddd
        endif()
Toshihiro Shimizu 890ddd
        set(OUTLIST ${OUTLIST} ${LIBPATH})
Toshihiro Shimizu 890ddd
    endforeach()
Toshihiro Shimizu 890ddd
    set(${OUT_LIB_LIST} ${OUTLIST})
Toshihiro Shimizu 890ddd
endmacro()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
set(TNZSTDFX_Location)
Toshihiro Shimizu 890ddd
set(TFARM_Location)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
if(WIN32)
Toshihiro Shimizu 890ddd
    if (CMAKE_SIZEOF_VOID_P EQUAL 4)
Toshihiro Shimizu 890ddd
        set(PLATFORM 32)
Toshihiro Shimizu 890ddd
        set(PLATFORM2)
Toshihiro Shimizu 890ddd
    else()
Toshihiro Shimizu 890ddd
        set(PLATFORM 64)
Toshihiro Shimizu 890ddd
        set(PLATFORM2 _64)
Toshihiro Shimizu 890ddd
    endif()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
    set(GLUT_LIB ${SDKROOT}/glut/3.7.6/lib/glut${PLATFORM}.lib)
Toshihiro Shimizu 890ddd
    set(GL_LIB opengl32.lib)
Toshihiro Shimizu 890ddd
    set(Z_LIB
Toshihiro Shimizu 890ddd
        optimized ${SDKROOT}/zlib/zlib-1.2.7/lib/zlib-1.2.7${PLATFORM2}.lib
Toshihiro Shimizu 890ddd
        debug ${SDKROOT}/zlib/zlib-1.2.7/lib/zlib-1.2.7${PLATFORM2}d.lib)
Toshihiro Shimizu 890ddd
    set(JPEG_LIB ${SDKROOT}/LibJPEG/jpeg-9/lib/LibJPEG-9${PLATFORM2}.lib)
kusano 3f5122
    set(TIFF_INCLUDE_DIR ${SDKROOT}/tiff-4.0.3/libtiff)
Toshihiro Shimizu 890ddd
    set(TIFF_LIB
kusano 3f5122
        optimized ${SDKROOT}/tiff-4.0.3/lib/LibTIFF-4.0.3${PLATFORM2}.lib
kusano 3f5122
        debug  ${SDKROOT}/tiff-4.0.3/lib/LibTIFF-4.0.3${PLATFORM2}d.lib)
kusano 3f5122
    set(PNG_LIB
kusano 3f5122
        optimized ${SDKROOT}/libpng-1.6.21/lib/libpng16${PLATFORM2}.lib
kusano 3f5122
        debug  ${SDKROOT}/libpng-1.6.21/lib/libpng16${PLATFORM2}d.lib)
Toshihiro Shimizu 890ddd
    set(GLEW_LIB ${SDKROOT}/glew/glew-1.9.0/lib/glew${PLATFORM}.lib)
Toshihiro Shimizu 890ddd
    set(LZ4_LIB ${SDKROOT}/Lz4/Lz4_131/lz4_${PLATFORM}.lib)
Toshihiro Shimizu 890ddd
    set(SUPERLU_LIB ${SDKROOT}/superlu/SuperLU_${PLATFORM}.lib)
Toshihiro Shimizu 890ddd
    set(OPENBLAS_LIB ${SDKROOT}/openblas/libopenblas_${PLATFORM}.lib)
Toshihiro Shimizu 890ddd
    set(USB_LIB)  # unused
Toshihiro Shimizu 890ddd
    if (PLATFORM EQUAL 32)
Toshihiro Shimizu 890ddd
        set(QT_LIB ${SDKROOT}/quicktime/QT73SDK/Libraries/QTMLClient.lib)
Toshihiro Shimizu 890ddd
    endif()
Toshihiro Shimizu 890ddd
else()
Toshihiro Shimizu 890ddd
    find_library(GLUT_LIB GLUT)
Toshihiro Shimizu 890ddd
    find_library(GL_LIB OpenGL)
Toshihiro Shimizu 890ddd
    find_library(Z_LIB z)
roentgen 19af1b
fukasawa e60969
    find_package(TIFF REQUIRED)
fukasawa e60969
    set(TIFF_LIB ${TIFF_LIBRARY})
roentgen 19af1b
    # the libraries have not .pc nor preferred Find*.cmake. use custom modules.
fukasawa e60969
    find_package(PNG REQUIRED)
fukasawa e60969
    message("******* libpng:" ${PNG_LIBRARY})
fukasawa e60969
    set(PNG_LIB ${PNG_LIBRARY})
roentgen 19af1b
    find_package(GLEW)
roentgen 19af1b
roentgen 19af1b
    find_package(SuperLU REQUIRED)
roentgen 19af1b
    set(SUPERLU_INCLUDE_DIR ${SUPERLU_INCLUDE_DIR}/superlu)
roentgen 19af1b
    set(SUPERLU_LIB ${SUPERLU_LIBRARY})
roentgen 19af1b
    message("SuperLU:" ${SUPERLU_INCLUDE_DIR})
roentgen 19af1b
roentgen 19af1b
    find_package(LZO REQUIRED)
roentgen 19af1b
    message("LZO:" ${LZO_INCLUDE_DIR})
roentgen 19af1b
roentgen 19af1b
    find_package(JPEG REQUIRED)
roentgen 19af1b
roentgen 19af1b
    # the libraries have .pc
roentgen 19af1b
    find_package(PkgConfig)
roentgen 19af1b
    if(GLEW-NOTFOUND)
roentgen 19af1b
        pkg_check_modules(GLEW REQUIRED glew)
roentgen 19af1b
    endif()
roentgen 19af1b
    set(GLEW_LIB ${GLEW_LIBRARIES})
roentgen 19af1b
roentgen 19af1b
    pkg_check_modules(LZ4_LIB REQUIRED liblz4)
roentgen 19af1b
roentgen 19af1b
    message("**************** lz4 lib:" ${LZ4_LIB_INCLUDE_DIRS})
roentgen 19af1b
    find_path(LZ4_STATIC lz4frame_static.h PATH ${LZ4_LIB_INCLUDE_DIRS})
roentgen 19af1b
    if(LZ4_STATIC-FOUND)
roentgen 19af1b
       add_definitions(-DLZ4_STATIC)
roentgen 19af1b
    endif()
roentgen 19af1b
roentgen 19af1b
    pkg_check_modules(USB_LIB REQUIRED libusb-1.0)
Toshihiro Shimizu 890ddd
    set(OPENBLAS_LIB) # unused?
Toshihiro Shimizu 890ddd
    if (PLATFORM EQUAL 32)
Toshihiro Shimizu 890ddd
        find_library(QT_LIB QuickTime)
Toshihiro Shimizu 890ddd
    endif()
roentgen 19af1b
roentgen 19af1b
    set(JPEG_LIB ${JPEG_LIBRARY})
roentgen 19af1b
    set(LZ4_LIB ${LZ4_LIB_LDFLAGS})
Toshihiro Shimizu 890ddd
endif()
Toshihiro Shimizu 890ddd
fukasawa e60969
find_path(BOOST_ROOT include/boost boost HINTS ${THIRDPARTY_LIBS_HINTS} PATH_SUFFIXES boost155/1.55.0_1 boost/boost_1_55_0/)
roentgen 19af1b
find_package(Boost 1.55 EXACT REQUIRED)
roentgen 19af1b
roentgen 19af1b
include_directories(${Boost_INCLUDE_DIR} ${LZ4_LIB_INCLUDE_DIRS} ${USB_LIB_INCLUDE_DIRS} ${SUPERLU_INCLUDE_DIR} ${JPEG_INCLUDE_DIR})
roentgen 19af1b
Toshihiro Shimizu 890ddd
if(WIN32 AND PLATFORM EQUAL 64)
Toshihiro Shimizu 890ddd
    add_definitions(-Dx64)
Toshihiro Shimizu 890ddd
endif()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
if(WIN32)
Toshihiro Shimizu 890ddd
    # place Toonz.exe and dlls in the same directory
Toshihiro Shimizu 890ddd
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
Toshihiro Shimizu 890ddd
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
Toshihiro Shimizu 890ddd
endif()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
# generate Qt translations and messages
Toshihiro Shimizu 890ddd
set(LANGUAGES japanese italian french)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
function(add_translation module)
Toshihiro Shimizu 890ddd
    set(translation)
Toshihiro Shimizu 890ddd
    foreach(lang ${LANGUAGES})
Toshihiro Shimizu 890ddd
        set(name "${CMAKE_SOURCE_DIR}/translations/${lang}/${module}.ts")
Toshihiro Shimizu 890ddd
        list(APPEND translation ${name})
Toshihiro Shimizu 890ddd
        set_source_files_properties(${name} PROPERTIES
Toshihiro Shimizu 890ddd
            OUTPUT_LOCATION "${CMAKE_BINARY_DIR}/loc/${lang}")
Toshihiro Shimizu 890ddd
    endforeach()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
    qt5_create_translation(message ${translation} ${ARGN})
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
    add_custom_target("translation_${module}" DEPENDS ${message})
Toshihiro Shimizu 890ddd
    set_target_properties("translation_${module}" PROPERTIES
Toshihiro Shimizu 890ddd
        EXCLUDE_FROM_DEFAULT_BUILD TRUE)
Toshihiro Shimizu 890ddd
endfunction()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
add_subdirectory(tnzcore)
Toshihiro Shimizu 890ddd
add_subdirectory(tnzbase)
Toshihiro Shimizu 890ddd
add_subdirectory(tnzext)
Toshihiro Shimizu 890ddd
add_subdirectory(toonzlib)
Toshihiro Shimizu 890ddd
add_subdirectory(toonzfarm/tfarm)
Toshihiro Shimizu 890ddd
add_subdirectory(stdfx)
Toshihiro Shimizu 890ddd
add_subdirectory(sound)
Toshihiro Shimizu 890ddd
add_subdirectory(colorfx)
Toshihiro Shimizu 890ddd
add_subdirectory(image)
Toshihiro Shimizu 890ddd
add_subdirectory(toonzqt)
Toshihiro Shimizu 890ddd
add_subdirectory(tnztools)
Toshihiro Shimizu 890ddd
add_subdirectory(toonz)
Toshihiro Shimizu 890ddd
roentgen 19af1b
find_path(LZODRIVER lzodriver HINTS ${THIRDPARTY_LIBS_HINTS})
roentgen 19af1b
if(LZODRIVER-FOUND)
roentgen 19af1b
    set(LZODRIVER-FOUND true)
roentgen 19af1b
    add_subdirectory(${SDKROOT}/lzo/driver lzodriver)
roentgen 19af1b
endif()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
add_subdirectory(tcleanupper)
Toshihiro Shimizu 890ddd
add_subdirectory(tcomposer)
Toshihiro Shimizu 890ddd
add_subdirectory(tconverter)
Toshihiro Shimizu 890ddd
add_subdirectory(toonzfarm)
Toshihiro Shimizu 890ddd
if(PLATFORM EQUAL 32)
Toshihiro Shimizu 890ddd
    add_subdirectory(t32bitsrv)
Toshihiro Shimizu 890ddd
endif()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
if (APPLE)
Toshihiro Shimizu 890ddd
    add_custom_command(TARGET executable
Toshihiro Shimizu 890ddd
        POST_BUILD COMMAND
Toshihiro Shimizu 890ddd
        ${CMAKE_INSTALL_NAME_TOOL} -add_rpath ${CMAKE_INSTALL_RPATH}
Toshihiro Shimizu 890ddd
        $<target_file:executable>)</target_file:executable>
Toshihiro Shimizu 890ddd
endif (APPLE)