Jeremy Bullock f15907
cmake_minimum_required(VERSION 2.8.11)
Campbell Barton a3a77b
Campbell Barton a3a77b
set(CMAKE_BUILD_TYPE_INIT Release)
Campbell Barton a3a77b
Toshihiro Shimizu 890ddd
project(OpenToonz)
Toshihiro Shimizu 890ddd
Campbell Barton 6c644b
Campbell Barton 6c644b
#-----------------------------------------------------------------------------
Campbell Barton 6c644b
# Platform Specific Defaults
Campbell Barton 6c644b
Campbell Barton 6c644b
# list of var-names
Campbell Barton 6c644b
set(_init_vars)
Campbell Barton 6c644b
429ee8
#-----------------------------------------------------------------------------
429ee8
# Select build target
429ee8
set(BUILD_TARGET_WIN       OFF)
429ee8
set(BUILD_TARGET_APPLE     OFF)
429ee8
set(BUILD_TARGET_UNIX      OFF)
429ee8
if(WIN32)
429ee8
    set(BUILD_TARGET_WIN    ON)
429ee8
    message(STATUS "Target system is WIN")
429ee8
elseif(APPLE)
429ee8
    set(BUILD_TARGET_APPLE  ON)
429ee8
    message(STATUS "Target system is APPLE")
429ee8
elseif(UNIX)
429ee8
    set(BUILD_TARGET_UNIX   ON)
429ee8
    message(STATUS "Target system is UNIX")
429ee8
else()
429ee8
    set(BUILD_TARGET_UNIX   ON)
429ee8
    message(WARNING "Target system unknown, set UNIX by default")
429ee8
    message(STATUS "Target system is UNIX (actually unknown)")
429ee8
endif()
429ee8
429ee8
#-----------------------------------------------------------------------------
429ee8
# Select build environment
429ee8
429ee8
set(BUILD_ENV_MSVC     OFF)
429ee8
set(BUILD_ENV_APPLE    OFF)
429ee8
set(BUILD_ENV_UNIXLIKE OFF)
429ee8
if(MSVC)
429ee8
    set(BUILD_ENV_MSVC ON)
429ee8
    if(NOT BUILD_TARGET_WIN)
429ee8
        message(WARNING "Build environment is MSVC, but target system is not WIN")
429ee8
    endif()
429ee8
    message(STATUS "Build environment is MSVC")
429ee8
elseif(CMAKE_HOST_APPLE)
429ee8
    set(BUILD_ENV_APPLE ON)
429ee8
    if(NOT BUILD_TARGET_APPLE)
429ee8
        message(WARNING "Build environment is APPLE, but target system is not APPLE")
429ee8
    endif()
429ee8
    message(STATUS "Build environment is APPLE")
429ee8
elseif(CMAKE_HOST_UNIX OR CMAKE_COMPILER_IS_GNUCC)
429ee8
    set(BUILD_ENV_UNIXLIKE ON)
429ee8
    if(NOT BUILD_TARGET_UNIX AND NOT BUILD_TARGET_WIN)
429ee8
        message(WARNING "Build environment is UNIXLIKE, but target system is not UNIX or WIN")
429ee8
    endif()
429ee8
    message(STATUS "Build environment is UNIXLIKE")
429ee8
else()
429ee8
    message(ERROR "Unsupported build environment, only MSVC, APPLE and UNIXLIKE are supported")
429ee8
endif()
429ee8
429ee8
Campbell Barton 6c644b
# initialize to ON
Campbell Barton 6c644b
macro(option_defaults_init)
Campbell Barton 6c644b
    foreach(_var ${ARGV})
Campbell Barton 6c644b
        set(${_var} ON)
Campbell Barton 6c644b
        list(APPEND _init_vars "${_var}")
Campbell Barton 6c644b
    endforeach()
Campbell Barton 6c644b
    unset(_var)
Campbell Barton 6c644b
endmacro()
Campbell Barton 6c644b
Campbell Barton 6c644b
# remove from namespace
Campbell Barton 6c644b
macro(option_defaults_clear)
Campbell Barton 6c644b
    foreach(_var ${_init_vars})
Campbell Barton 6c644b
        unset(${_var})
Campbell Barton 6c644b
    endforeach()
Campbell Barton 6c644b
    unset(_var)
Campbell Barton 6c644b
    unset(_init_vars)
Campbell Barton 6c644b
endmacro()
Campbell Barton 6c644b
Campbell Barton 6c644b
# values to initialize WITH_****
Campbell Barton 6c644b
option_defaults_init(
Campbell Barton 6c644b
    _init_SYSTEM_LZO
Campbell Barton 6c644b
)
Campbell Barton 6c644b
Campbell Barton 6c644b
# customize...
429ee8
if(BUILD_ENV_MSVC)
Campbell Barton 6c644b
    set(_init_SYSTEM_LZO                     OFF)
Campbell Barton cead1b
    set(_init_SYSTEM_SUPERLU                 OFF)
429ee8
elseif(BUILD_ENV_APPLE)
Campbell Barton 6c644b
    set(_init_SYSTEM_LZO                     OFF)
Campbell Barton cead1b
    set(_init_SYSTEM_SUPERLU                 OFF)
429ee8
elseif(BUILD_ENV_UNIXLIKE)
Campbell Barton 6c644b
    set(_init_SYSTEM_LZO                     ON)
Campbell Barton cead1b
    set(_init_SYSTEM_SUPERLU                 ON)
Campbell Barton 6c644b
endif()
Campbell Barton 6c644b
Campbell Barton 6c644b
Campbell Barton 6c644b
#-----------------------------------------------------------------------------
Campbell Barton 6c644b
# Build Options
Campbell Barton 6c644b
Campbell Barton 6c644b
option(WITH_SYSTEM_LZO "Use the system LZO library instead of 'thirdpary'" ${_init_SYSTEM_LZO})
Campbell Barton cead1b
option(WITH_SYSTEM_SUPERLU "Use the system SuperLU library instead of 'thirdpary'" ${_init_SYSTEM_SUPERLU})
Jeremy Bullock f15907
option(WITH_STOPMOTION "Build with Stop Motion features - Requires Canon SDK" OFF)
Campbell Barton 6c644b
Campbell Barton 6c644b
# avoid using again
Campbell Barton 6c644b
option_defaults_clear()
Campbell Barton 6c644b
Campbell Barton 6c644b
# end option(...)
Campbell Barton 6c644b
Campbell Barton 6c644b
Campbell Barton 6c644b
#-----------------------------------------------------------------------------
Campbell Barton 6c644b
# Third Party & System Libs
Campbell Barton 6c644b
Campbell Barton 8d5334
include(${CMAKE_SOURCE_DIR}/../cmake/util_compiler.cmake)
Campbell Barton 8d5334
Toshihiro Shimizu 890ddd
get_filename_component(SDKROOT ../../thirdparty/ ABSOLUTE)
Campbell Barton 326eaa
message(STATUS "SDK Root:" ${SDKROOT})
jpumc a8cd98
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake")
429ee8
if(BUILD_ENV_APPLE)
roentgen 19af1b
    set(THIRDPARTY_LIBS_HINTS "/usr/local/Cellar/" "/opt/include" ${SDKROOT})
429ee8
elseif(BUILD_ENV_MSVC OR BUILD_ENV_UNIXLIKE)
roentgen 19af1b
    set(THIRDPARTY_LIBS_HINTS ${SDKROOT})
roentgen 19af1b
endif()
roentgen 19af1b
Campbell Barton 326eaa
message(STATUS "Thirdpary Library Search path:" ${THIRDPARTY_LIBS_HINTS})
Toshihiro Shimizu 890ddd
429ee8
if(BUILD_ENV_MSVC)
Shinya Kitaoka fd19c4
    if(MSVC_VERSION GREATER 1800)
Shinya Kitaoka fd19c4
        if(CMAKE_SIZEOF_VOID_P EQUAL 4)
shun_iwasawa 31362d
            set(QT_PATH "C:/Qt/5.9.2/msvc2015" CACHE PATH "Qt instlattion directory")
Shinya Kitaoka fd19c4
        else()
shun_iwasawa 31362d
            set(QT_PATH "C:/Qt/5.9.2/msvc2015_64" CACHE PATH "Qt instlattion directory")
Shinya Kitaoka fd19c4
        endif()
Shinya Kitaoka aa5907
    else()
Shinya Kitaoka fd19c4
        if(CMAKE_SIZEOF_VOID_P EQUAL 4)
shun_iwasawa 31362d
            set(QT_PATH "C:/Qt/5.9.2/msvc2013" CACHE PATH "Qt instlattion directory")
Shinya Kitaoka fd19c4
        else()
shun_iwasawa 31362d
            set(QT_PATH "C:/Qt/5.9.2/msvc2013_64" CACHE PATH "Qt instlattion directory")
Shinya Kitaoka fd19c4
        endif()
Shinya Kitaoka aa5907
    endif()
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/")
Shinya Kitaoka ee259f
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4251")
Shinya Kitaoka ee259f
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251")
Campbell Barton f2d492
    add_definitions(
Campbell Barton f2d492
        -DVC_EXTRALEAN
Campbell Barton f2d492
        -DNOMINMAX
Campbell Barton f2d492
        -D_USE_MATH_DEFINES
Campbell Barton f2d492
    )
429ee8
elseif(BUILD_ENV_APPLE)
Campbell Barton f08982
    if(NOT PLATFORM)
Toshihiro Shimizu 890ddd
        set(PLATFORM 64)
Toshihiro Shimizu 890ddd
    endif()
Toshihiro Shimizu 890ddd
    message("PLATFORM:" ${PLATFORM})
Campbell Barton f08982
    if(PLATFORM EQUAL 64)
shun_iwasawa 31362d
        set(QT_PATH "~/Qt5.9.2/5.9.2/clang_64/lib" CACHE PATH "Qt instlattion directory")
Shinya Kitaoka 2a1f2b
        set(QT_LIB_PATH "${QT_PATH}/")
Shinya Kitaoka 2a1f2b
        set(CMAKE_PREFIX_PATH "${QT_LIB_PATH}cmake/")
roentgen 19af1b
Toshihiro Shimizu 890ddd
        message("CMAKE_PREFIX_PATH:" ${CMAKE_PREFIX_PATH})
Campbell Barton f2d492
        add_definitions(
Campbell Barton f2d492
            -DMACOSX
Campbell Barton f2d492
            -Di386
Campbell Barton f2d492
        )
Toshihiro Shimizu 890ddd
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -std=c++11 -stdlib=libc++ -fno-implicit-templates")
Shinya Kitaoka 12c444
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
Toshihiro Shimizu 890ddd
    elseif(PLATFORM EQUAL 32)
shun_iwasawa 31362d
        set(QT_PATH "~/Qt5.9.2/5.9.2/clang_32/lib" CACHE PATH "Qt instlattion directory")
Shinya Kitaoka 2a1f2b
        set(QT_LIB_PATH "${QT_PATH}/")
Shinya Kitaoka 2a1f2b
        set(CMAKE_PREFIX_PATH "${QT_LIB_PATH}cmake/")
Shinya Kitaoka 2a1f2b
Toshihiro Shimizu 890ddd
        message("CMAKE_PREFIX_PATH:" ${CMAKE_PREFIX_PATH})
Campbell Barton f2d492
        add_definitions(
Campbell Barton f2d492
            -DMACOSX
Campbell Barton f2d492
            -Di386
Campbell Barton f2d492
        )
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()
429ee8
elseif(BUILD_ENV_UNIXLIKE)
Campbell Barton 22fd3b
    # Needed for correct Qt detection
Campbell Barton 22fd3b
    cmake_minimum_required(VERSION 2.8.12)
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    if(CMAKE_SIZEOF_VOID_P MATCHES "8")
Campbell Barton 22fd3b
        set(PLATFORM 64)
Campbell Barton 22fd3b
    else()
Campbell Barton 22fd3b
        set(PLATFORM 32)
Campbell Barton 22fd3b
    endif()
Campbell Barton 6f1225
    if(CMAKE_SYSTEM_NAME MATCHES "Linux")
Campbell Barton 22fd3b
        add_definitions(-DLINUX)
429ee8
    elseif(NOT BUILD_TARGET_WIN)
Campbell Barton 22fd3b
        message(WARNING "Support for generic Unix (Not Apple or Linux) isn't yet working!")
Campbell Barton 22fd3b
    endif()
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    set(CMAKE_CXX_STANDARD 11)
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    find_package(Qt5Widgets)
Campbell Barton 22fd3b
otakuto 34a7ce
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
otakuto 34a7ce
    if (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
otakuto 34a7ce
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++")
otakuto 34a7ce
    endif()
Campbell Barton f08982
endif()
Toshihiro Shimizu 890ddd
Campbell Barton f2d492
add_definitions(
Campbell Barton f2d492
    -DQT_GUI_LIB
Campbell Barton f2d492
    -DQT_NETWORK_LIB
Campbell Barton f2d492
    -DQT_CORE_LIB
Campbell Barton f2d492
    -DQT_SHARED
Campbell Barton f2d492
)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
# Find includes in corresponding build directories
Toshihiro Shimizu 890ddd
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Toshihiro Shimizu 890ddd
429ee8
if(BUILD_ENV_APPLE)
Shinya Kitaoka 7db469
    set(CMAKE_MACOSX_RPATH ON)
Shinya Kitaoka 7db469
    set(CMAKE_SKIP_BUILD_RPATH FALSE)
tomosu 9cb984
    set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
Shinya Kitaoka 7db469
    set(CMAKE_INSTALL_RPATH ${QT_LIB_PATH})
Shinya Kitaoka 7db469
    set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
Shinya Kitaoka 7db469
    list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${QT_LIB_PATH}" isSystemDir)
Shinya Kitaoka 7db469
    if("${isSystemDir}" STREQUAL "-1")
Shinya Kitaoka 7db469
        set(CMAKE_INSTALL_RPATH "${QT_LIB_PATH}")
Shinya Kitaoka 7db469
    endif()
Shinya Kitaoka 7db469
endif()
Toshihiro Shimizu 890ddd
Campbell Barton 2e1cb6
include_directories(
Campbell Barton 2e1cb6
    include
Campbell Barton 2e1cb6
)
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
shun_iwasawa 21a6b6
    LinguistTools
Campbell Barton 9ece9c
    Multimedia
shun-iwasawa 5bdd2f
    MultimediaWidgets
Campbell Barton 9ece9c
)
Toshihiro Shimizu 890ddd
Campbell Barton 5bb68e
set(QT_MINIMUM_VERSION 5.5.0)
Campbell Barton 5bb68e
if(Qt5Core_VERSION VERSION_LESS QT_MINIMUM_VERSION)
Campbell Barton 5bb68e
    MESSAGE(FATAL_ERROR "Minimum supported Qt version: ${QT_MINIMUM_VERSION}.
Campbell Barton 5bb68e
    Installed version: ${Qt5Core_VERSION}")
Campbell Barton 5bb68e
endif()
Campbell Barton 5bb68e
unset(QT_MINIMUM_VERSION)
Campbell Barton 5bb68e
Jeremy Bullock f15907
if(BUILD_ENV_MSVC AND NOT WITH_STOPMOTION)
Jeremy Bullock f15907
    include_directories(
Jeremy Bullock f15907
        SYSTEM
Jeremy Bullock f15907
        ${SDKROOT}/glut/3.7.6/include
Jeremy Bullock f15907
        ${SDKROOT}/zlib-1.2.8
Jeremy Bullock f15907
        ${SDKROOT}/LibJPEG/jpeg-9
Jeremy Bullock f15907
    )
Jeremy Bullock f15907
    add_definitions(
Jeremy Bullock f15907
        -DGLUT_NO_LIB_PRAGMA
Jeremy Bullock f15907
    )
Jeremy Bullock f15907
endif()
Jeremy Bullock f15907
Jeremy Bullock f15907
if(BUILD_ENV_MSVC AND WITH_STOPMOTION)
shun-iwasawa 590082
    find_package(OpenCV 4.1 REQUIRED)
Toshihiro Shimizu 890ddd
    include_directories(
Campbell Barton a9c3da
        SYSTEM
Toshihiro Shimizu 890ddd
        ${SDKROOT}/glut/3.7.6/include
kusano 897736
        ${SDKROOT}/zlib-1.2.8
Campbell Barton 2e1cb6
        ${SDKROOT}/LibJPEG/jpeg-9
Jeremy Bullock f15907
        ${SDKROOT}/canon/Header
Jeremy Bullock f15907
        ${SDKROOT}/libjpeg-turbo64/include
shun-iwasawa 590082
        ${OpenCV_INCLUDE_DIRS}
Campbell Barton 2e1cb6
    )
Campbell Barton f2d492
    add_definitions(
Campbell Barton f2d492
        -DGLUT_NO_LIB_PRAGMA
Campbell Barton f2d492
    )
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)
Campbell Barton 326eaa
message(STATUS "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 が走るときにはできていないので完全なパス名を生成して返すだけ
429ee8
        if(BUILD_ENV_APPLE)
John Dancel 83fae9
            set(LIBPATH "\$<target_file:${arg}>")</target_file:${arg}>
Campbell Barton 22fd3b
        else()
Campbell Barton 22fd3b
            set(LIBPATH ${arg})
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
429ee8
set(QT_LIB)  # avoid warning
429ee8
429ee8
if(BUILD_ENV_MSVC)
Campbell Barton f08982
    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
Shinya Kitaoka fd19c4
    if(MSVC_VERSION GREATER 1800)
Shinya Kitaoka fd19c4
        set(MSVC_LIB_VERSION 2015)
Shinya Kitaoka fd19c4
    else()
Shinya Kitaoka fd19c4
        set(MSVC_LIB_VERSION 2013)
Shinya Kitaoka fd19c4
    endif()
Shinya Kitaoka fd19c4
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
Shinya Kitaoka fd19c4
        optimized ${SDKROOT}/zlib-1.2.8/lib/zlib-1.2.8_${MSVC_LIB_VERSION}${PLATFORM2}.lib
Campbell Barton 9ece9c
        debug ${SDKROOT}/zlib-1.2.8/lib/zlib-1.2.8_${MSVC_LIB_VERSION}${PLATFORM2}d.lib
Campbell Barton 9ece9c
    )
Shinya Kitaoka fd19c4
    set(JPEG_LIB ${SDKROOT}/LibJPEG/jpeg-9/lib/LibJPEG-9_${MSVC_LIB_VERSION}${PLATFORM2}.lib)
kusano 3f5122
    set(TIFF_INCLUDE_DIR ${SDKROOT}/tiff-4.0.3/libtiff)
Toshihiro Shimizu 890ddd
    set(TIFF_LIB
Shinya Kitaoka fd19c4
        optimized ${SDKROOT}/tiff-4.0.3/lib/LibTIFF-4.0.3_${MSVC_LIB_VERSION}${PLATFORM2}.lib
Campbell Barton 9ece9c
        debug  ${SDKROOT}/tiff-4.0.3/lib/LibTIFF-4.0.3_${MSVC_LIB_VERSION}${PLATFORM2}d.lib
Campbell Barton 9ece9c
    )
kusano 3f5122
    set(PNG_LIB
Shinya Kitaoka fd19c4
        optimized ${SDKROOT}/libpng-1.6.21/lib/libpng16_${MSVC_LIB_VERSION}${PLATFORM2}.lib
Campbell Barton 9ece9c
        debug  ${SDKROOT}/libpng-1.6.21/lib/libpng16_${MSVC_LIB_VERSION}${PLATFORM2}d.lib
Campbell Barton 9ece9c
    )
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)
Shinya Kitaoka fd19c4
    set(SUPERLU_LIB ${SDKROOT}/superlu/SuperLU_${MSVC_LIB_VERSION}_${PLATFORM}.lib)
Toshihiro Shimizu 890ddd
    set(OPENBLAS_LIB ${SDKROOT}/openblas/libopenblas_${PLATFORM}.lib)
Toshihiro Shimizu 890ddd
    set(USB_LIB)  # unused
Jeremy Bullock f15907
    if (WITH_STOPMOTION)
shun-iwasawa 590082
        set(CANON_LIB ${SDKROOT}/canon/library/EDSDK.lib)
shun-iwasawa 590082
        set(TURBOJPEG_LIB ${SDKROOT}/libjpeg-turbo64/lib/turbojpeg.lib)
Jeremy Bullock f15907
    endif()
Campbell Barton f08982
    if(PLATFORM EQUAL 32)
Toshihiro Shimizu 890ddd
        set(QT_LIB ${SDKROOT}/quicktime/QT73SDK/Libraries/QTMLClient.lib)
Toshihiro Shimizu 890ddd
    endif()
bf1d82
    set(MYPAINT_LIB_INCLUDE_DIRS ${SDKROOT}/libmypaint/dist/${PLATFORM}/include/libmypaint)
bf1d82
    set(MYPAINT_LIB_LDFLAGS ${SDKROOT}/libmypaint/dist/${PLATFORM}/libmypaint.lib)
429ee8
elseif(BUILD_ENV_APPLE)
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(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)
Campbell Barton fb6d38
        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?
Campbell Barton f08982
    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})
roentgen 3047bb
roentgen 3047bb
    find_package(LZO REQUIRED)
roentgen 3047bb
    message("LZO:" ${LZO_INCLUDE_DIR})
Campbell Barton 22fd3b
bf1d82
    pkg_check_modules(MYPAINT_LIB REQUIRED libmypaint)
429ee8
elseif(BUILD_ENV_UNIXLIKE)
429ee8
    if(BUILD_TARGET_WIN)
429ee8
        find_library(GL_LIB opengl32)
429ee8
        find_library(GLU_LIB glu32)
429ee8
        find_library(GLUT_LIB NAMES glut freeglut)
429ee8
    else()
429ee8
        find_library(GL_LIB GL)
429ee8
        find_library(GLU_LIB GLU)
429ee8
        find_library(GLUT_LIB glut)
429ee8
    endif()
Campbell Barton 22fd3b
    find_library(Z_LIB z)
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    find_package(TIFF REQUIRED)
Campbell Barton 22fd3b
    find_package(PNG REQUIRED)
Campbell Barton 22fd3b
    set(PNG_LIB ${PNG_LIBRARY})
Campbell Barton 22fd3b
    message("******* libpng:" ${PNG_LIB})
Campbell Barton 22fd3b
    find_package(GLEW)
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    find_package(SuperLU REQUIRED)
Campbell Barton 22fd3b
    set(SUPERLU_LIB ${SUPERLU_LIBRARY})
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    find_package(JPEG REQUIRED)
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    # the libraries have .pc
Campbell Barton 22fd3b
    find_package(PkgConfig)
Michał Janiszewski 6dc4b9
Michał Janiszewski 6dc4b9
    # This is not required for OpenToonz itself, but libtiff will pick it up if
Michał Janiszewski 6dc4b9
    # present and libimage won't be aware causing linker to fail
Michał Janiszewski 6dc4b9
    pkg_check_modules(LZMA liblzma)
Michał Janiszewski 6dc4b9
    set(TIFF_LIB ${TIFF_LIBRARY} ${LZMA_LIBRARIES})
Michał Janiszewski 6dc4b9
Campbell Barton 22fd3b
    if(GLEW-NOTFOUND)
Campbell Barton 22fd3b
        pkg_check_modules(GLEW REQUIRED glew)
Campbell Barton 22fd3b
    endif()
Campbell Barton 22fd3b
    set(GLEW_LIB ${GLEW_LIBRARIES})
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    pkg_check_modules(LZ4_LIB REQUIRED liblz4)
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    message("**************** lz4 lib:" ${LZ4_LIB_INCLUDE_DIRS})
Campbell Barton 22fd3b
    find_path(LZ4_STATIC lz4frame_static.h PATH ${LZ4_LIB_INCLUDE_DIRS})
Campbell Barton 22fd3b
    if(LZ4_STATIC-FOUND)
Campbell Barton fb6d38
        add_definitions(-DLZ4_STATIC)
Campbell Barton 22fd3b
    endif()
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    # TODO: check for them properly in some sane order with pkg-config
Campbell Barton 22fd3b
    find_library(OPENBLAS_LIB NAMES cblas gslcblas openblas blas)
Campbell Barton 22fd3b
    message("OpenBLAS:" ${OPENBLAS_LIB})
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    set(JPEG_LIB ${JPEG_LIBRARY})
Campbell Barton 22fd3b
    set(LZ4_LIB ${LZ4_LIB_LDFLAGS})
Campbell Barton 22fd3b
Campbell Barton 22fd3b
    find_package(LZO REQUIRED)
Campbell Barton 22fd3b
    message("LZO:" ${LZO_INCLUDE_DIR})
Campbell Barton 22fd3b
429ee8
    if(NOT BUILD_TARGET_WIN)
429ee8
        pkg_check_modules(USB_LIB REQUIRED libusb-1.0)
429ee8
        pkg_check_modules(FREETYPE REQUIRED freetype2)
429ee8
    endif()
Campbell Barton fc1e00
    # Can be 'libmypaint' or 'libmypaint-1.x'
Campbell Barton b0ee30
    pkg_search_module(MYPAINT_LIB REQUIRED libmypaint libmypaint-1.3>=1.3)
Toshihiro Shimizu 890ddd
endif()
Toshihiro Shimizu 890ddd
Campbell Barton 8d5334
Campbell Barton a0c6e1
include(TestBigEndian)
Campbell Barton a0c6e1
test_big_endian(_SYSTEM_BIG_ENDIAN)
Campbell Barton a0c6e1
if(_SYSTEM_BIG_ENDIAN)
Campbell Barton a0c6e1
    add_definitions(-DTNZ_LITTLE_ENDIAN=0)
Campbell Barton a0c6e1
else()
Campbell Barton a0c6e1
    add_definitions(-DTNZ_LITTLE_ENDIAN=1)
Campbell Barton a0c6e1
endif()
Campbell Barton a0c6e1
unset(_SYSTEM_BIG_ENDIAN)
Campbell Barton a0c6e1
Campbell Barton a0c6e1
Campbell Barton 8d5334
set(C_WARNINGS)
Campbell Barton 8d5334
set(CXX_WARNINGS)
Campbell Barton 8d5334
Campbell Barton 8d5334
if(CMAKE_COMPILER_IS_GNUCC)
Campbell Barton 8d5334
    ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
Campbell Barton 8d5334
    ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEF -Wundef)
Campbell Barton 8c6c57
    ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
Campbell Barton 8d5334
Campbell Barton 8d5334
    ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_WRITE_STRINGS -Wwrite-strings)
Campbell Barton 8d5334
    ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
Campbell Barton 8c6c57
    ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
Campbell Barton 8d5334
endif()
Campbell Barton 8d5334
Campbell Barton 8d5334
Campbell Barton 2e1cb6
include_directories(
Campbell Barton a9c3da
    SYSTEM
Campbell Barton 2e1cb6
    BEFORE
Campbell Barton 2e1cb6
    ${TIFF_INCLUDE_DIR}
Campbell Barton 2e1cb6
    ${PNG_INCLUDE_DIRS}
Campbell Barton 2e1cb6
)
Michael Cullen b49802
429ee8
if(BUILD_ENV_MSVC OR BUILD_ENV_APPLE)
Campbell Barton 2e1cb6
    find_path(
Campbell Barton 2e1cb6
        BOOST_ROOT
Campbell Barton 2e1cb6
            include/boost
Campbell Barton 2e1cb6
            boost
Campbell Barton 2e1cb6
        HINTS
Campbell Barton 2e1cb6
            ${THIRDPARTY_LIBS_HINTS}
Campbell Barton 2e1cb6
        PATH_SUFFIXES
Campbell Barton 2e1cb6
            boost/boost_1_61_0/
Campbell Barton 2e1cb6
            boost/boost_1_60_0/
Campbell Barton 2e1cb6
            boost/boost_1_59_0/
Campbell Barton 2e1cb6
            boost/boost_1_58_0/
Campbell Barton 2e1cb6
            boost/boost_1_57_0/
Campbell Barton 2e1cb6
            boost/boost_1_56_0/
Campbell Barton 2e1cb6
            boost155/1.55.0_1/
Campbell Barton 2e1cb6
            boost/boost_1_55_0/
Campbell Barton 2e1cb6
    )
Campbell Barton 89a491
    find_package(Boost 1.55 REQUIRED)
Campbell Barton 89a491
else()
Campbell Barton 89a491
    find_package(Boost)
Campbell Barton 22fd3b
endif()
roentgen 19af1b
Campbell Barton 2e1cb6
include_directories(
Campbell Barton a9c3da
    SYSTEM
Campbell Barton 2e1cb6
    ${Boost_INCLUDE_DIR}
Campbell Barton 2e1cb6
    ${LZ4_LIB_INCLUDE_DIRS}
Campbell Barton 2e1cb6
    ${USB_LIB_INCLUDE_DIRS}
Campbell Barton 2e1cb6
    ${SUPERLU_INCLUDE_DIR}
Campbell Barton 2e1cb6
    ${JPEG_INCLUDE_DIR}
bf1d82
    ${MYPAINT_LIB_INCLUDE_DIRS}
Campbell Barton 2e1cb6
)
roentgen 19af1b
429ee8
if(BUILD_TARGET_WIN AND PLATFORM EQUAL 64)
Toshihiro Shimizu 890ddd
    add_definitions(-Dx64)
Toshihiro Shimizu 890ddd
endif()
Toshihiro Shimizu 890ddd
429ee8
if(BUILD_ENV_MSVC)
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")
429ee8
elseif(BUILD_ENV_APPLE)
Campbell Barton 22fd3b
    # pass
429ee8
elseif(BUILD_ENV_UNIXLIKE)
Campbell Barton b45a54
    set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
Campbell Barton b45a54
Campbell Barton 3158be
    # Mirror relative bin/lib location for installation
Campbell Barton 3158be
    # so the generated shell script works in both cases.
Campbell Barton 3158be
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/opentoonz)
Campbell Barton 3158be
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/opentoonz)
Campbell Barton b45a54
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
Campbell Barton 3158be
Campbell Barton 3158be
    if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
Campbell Barton 3158be
        set(CMAKE_INSTALL_PREFIX "/opt/opentoonz" CACHE PATH "OpenToonz install prefix" FORCE)
Campbell Barton 3158be
    endif()
Toshihiro Shimizu 890ddd
endif()
Toshihiro Shimizu 890ddd
429ee8
if(BUILD_ENV_MSVC AND MSVC_VERSION EQUAL 1800)
kusano 543ae7
    # Visual C++ 2013 cannot handle UTF-8 without BOM
kusano 543ae7
    # Non-ascii characters in comments would not be a problem
kusano 543ae7
    add_compile_options("/wd4819")
kusano 543ae7
endif()
kusano 543ae7
Toshihiro Shimizu 890ddd
# generate Qt translations and messages
shun-iwasawa 17984e
set(LANGUAGES japanese italian french spanish chinese german russian korean czech)
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
Campbell Barton 9ece9c
            OUTPUT_LOCATION "${CMAKE_BINARY_DIR}/loc/${lang}"
Campbell Barton 9ece9c
        )
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
Campbell Barton 9ece9c
        EXCLUDE_FROM_DEFAULT_BUILD TRUE
Campbell Barton 9ece9c
    )
Toshihiro Shimizu 890ddd
endfunction()
Toshihiro Shimizu 890ddd
Campbell Barton 8d5334
set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS}")
Campbell Barton 8d5334
set(CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")
Campbell Barton 8d5334
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
roentgen 3047bb
add_subdirectory(${SDKROOT}/lzo/driver lzodriver)
Toshihiro Shimizu 890ddd
Keisuke Ogaki 1a50d4
add_subdirectory(toonz)
Toshihiro Shimizu 890ddd
add_subdirectory(tcleanupper)
Toshihiro Shimizu 890ddd
add_subdirectory(tcomposer)
Toshihiro Shimizu 890ddd
add_subdirectory(tconverter)
Toshihiro Shimizu 890ddd
add_subdirectory(toonzfarm)
tomosu 9cb984
429ee8
if(BUILD_ENV_APPLE)
tomosu 9cb984
    add_subdirectory(mousedragfilter)
tomosu 9cb984
endif()
tomosu 9cb984
db7f14
if((PLATFORM EQUAL 32) AND ((BUILD_TARGET_WIN AND BUILD_ENV_MSVC) OR BUILD_TARGET_APPLE))
Toshihiro Shimizu 890ddd
    add_subdirectory(t32bitsrv)
Toshihiro Shimizu 890ddd
endif()
Toshihiro Shimizu 890ddd
429ee8
if(BUILD_ENV_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}
Campbell Barton 9ece9c
        $<target_file:executable></target_file:executable>
Campbell Barton 9ece9c
    )
shun-iwasawa a01b86
    # add capability for retina displays
shun-iwasawa f39ea0
    set_target_properties(OpenToonz PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/../cmake/BundleInfo.plist.in)
Campbell Barton f08982
endif()
eszlari e5a0a3
eszlari ad2efb
if(BUILD_ENV_UNIXLIKE AND NOT BUILD_TARGET_WIN)
eszlari ad2efb
    add_subdirectory(xdg-data)
eszlari e5a0a3
endif()