shun-iwasawa 799a29
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})
shun-iwasawa 31accf
option(WITH_CANON "Build with Canon DSLR support - Requires Canon SDK" OFF)
shun-iwasawa 799a29
option(WITH_TRANSLATION "Generate translation projects as well" ON)
shun-iwasawa 19cec1
option(WITH_WINTAB "(Windows only) Build with customized Qt with WinTab support. https://github.com/shun-iwasawa/qt5/releases/tag/v5.15.2_wintab" 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
shun-iwasawa 31accf
#-----------------------------------------------------------------------------
shun-iwasawa 31accf
# Platform Architecture
shun-iwasawa 31accf
shun-iwasawa 31accf
if(BUILD_ENV_APPLE)
shun-iwasawa 31accf
    if(NOT PLATFORM)
shun-iwasawa 31accf
        set(PLATFORM 64)
shun-iwasawa 31accf
    endif()
shun-iwasawa 31accf
else() # Windows and Linux case
shun-iwasawa 31accf
    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
shun-iwasawa 31accf
        set(PLATFORM 64)
shun-iwasawa 31accf
        set(PLATFORM2 _64)
shun-iwasawa 31accf
    elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
shun-iwasawa 31accf
        set(PLATFORM 32)
shun-iwasawa 31accf
        set(PLATFORM2)
shun-iwasawa 31accf
    else()
shun-iwasawa 31accf
        message("Warning : CMAKE_SIZEOF_VOID_P = ${CMAKE_SIZEOF_VOID_P}")
shun-iwasawa 31accf
        set(PLATFORM 64)
shun-iwasawa 31accf
        set(PLATFORM2 _64)
shun-iwasawa 31accf
    endif()
shun-iwasawa 31accf
endif()
shun-iwasawa 31accf
message("PLATFORM:" ${PLATFORM})
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)
shun-iwasawa 19cec1
    set(QT_PATH "C:/Qt/5.15.2/msvc2019${PLATFORM2}" CACHE PATH "Qt installation 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})
shun-iwasawa c85b38
    set(CMAKE_PREFIX_PATH "${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)
shun-iwasawa 31accf
    set(QT_PATH "~/Qt5.9.2/5.9.2/clang_${PLATFORM}/lib" CACHE PATH "Qt installation directory")
shun-iwasawa 31accf
    set(QT_LIB_PATH "${QT_PATH}/")
shun-iwasawa c85b38
    set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${QT_LIB_PATH}cmake/")
shun-iwasawa c85b38
    foreach(path ${CMAKE_PREFIX_PATH})
shun-iwasawa c85b38
      message("CMAKE_PREFIX_PATH: " ${path})
shun-iwasawa c85b38
    endforeach(path)
shun-iwasawa 31accf
    add_definitions(
shun-iwasawa 31accf
        -DMACOSX
shun-iwasawa 31accf
        -Di386
shun-iwasawa 31accf
        -D__MACOS__
shun-iwasawa 31accf
    )
Campbell Barton f08982
    if(PLATFORM EQUAL 64)
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)
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 6f1225
    if(CMAKE_SYSTEM_NAME MATCHES "Linux")
Campbell Barton 22fd3b
        add_definitions(-DLINUX)
Rozhuk Ivan ac51ab
    elseif(CMAKE_SYSTEM_NAME MATCHES "^.*BSD$|DragonFly")
Rozhuk Ivan ac51ab
        set(BUILD_TARGET_BSD ON)
Rozhuk Ivan ac51ab
        add_definitions(-D_BSD_SOURCE -DFREEBSD)
Rozhuk Ivan ac51ab
        include_directories("/usr/local/include/")
Rozhuk Ivan ac51ab
        message(STATUS "Configuring for BSD system")
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)
artisteacher cfc4b0
    set(CMAKE_FIND_FRAMEWORK LAST)
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
shun-iwasawa 31accf
    SerialPort
shun-iwasawa 9b2afe
    UiTools
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
shun-iwasawa 31accf
if(BUILD_ENV_MSVC)
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
shun-iwasawa 82a8f5
        #${SDKROOT}/LibJPEG/jpeg-9
shun-iwasawa 82a8f5
        ${SDKROOT}/libjpeg-turbo/include
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
shun-iwasawa 31accf
shun-iwasawa 31accf
if(PLATFORM EQUAL 64)
shun-iwasawa 31accf
    if(BUILD_ENV_UNIXLIKE)
shun-iwasawa 5cdfa5
        find_package(OpenCV REQUIRED)
shun-iwasawa 31accf
    else() # Windows and MacOS case
shun-iwasawa 31accf
        find_package(OpenCV 4.1 REQUIRED)
shun-iwasawa 31accf
    endif()
shun-iwasawa 82a8f5
    #include_directories(
shun-iwasawa 82a8f5
    #    ${SDKROOT}/libjpeg-turbo64/include
shun-iwasawa 82a8f5
    #)
shun-iwasawa 31accf
    if(WITH_CANON)
shun-iwasawa 31accf
        include_directories(
shun-iwasawa 31accf
            ${SDKROOT}/canon/Header
shun-iwasawa 31accf
        )
shun-iwasawa 31accf
    endif()
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)
shun-iwasawa 31accf
    set(MSVC_LIB_VERSION 2015)
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
    )
shun-iwasawa 82a8f5
    #set(JPEG_LIB ${SDKROOT}/LibJPEG/jpeg-9/lib/LibJPEG-9_${MSVC_LIB_VERSION}${PLATFORM2}.lib)
shun-iwasawa 82a8f5
    set(JPEG_LIB ${SDKROOT}/libjpeg-turbo/lib/jpeg-static_${MSVC_LIB_VERSION}${PLATFORM2}.lib)
shun-iwasawa 82a8f5
    set(TURBOJPEG_LIB ${SDKROOT}/libjpeg-turbo/lib/turbojpeg-static_${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
shun-iwasawa 31accf
    
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)
shun-iwasawa 31accf
shun-iwasawa 31accf
    if(PLATFORM EQUAL 64)
shun-iwasawa 31accf
        if (WITH_CANON)
shun-iwasawa 31accf
            set(CANON_LIB ${SDKROOT}/canon/library/EDSDK.lib)
shun-iwasawa 31accf
        endif()
shun-iwasawa 31accf
    endif()
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()
Tact Yoshida cc3dae
    if (TARGET GLEW::GLEW)
Tact Yoshida cc3dae
      set(GLEW_LIB GLEW::GLEW)
Tact Yoshida cc3dae
    else()
Tact Yoshida cc3dae
      set(GLEW_LIB ${GLEW_LIBRARIES})
Tact Yoshida cc3dae
    endif()
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)
shun-iwasawa 31accf
shun-iwasawa 31accf
    if(PLATFORM EQUAL 64)
shun-iwasawa 31accf
    	pkg_check_modules(TURBOJPEG REQUIRED libturbojpeg)
shun-iwasawa 31accf
        find_library(TURBOJPEG_LIB turbojpeg ${TURBOJPEG_LIBRARY_DIRS})
shun-iwasawa 31accf
        message("**************** turbojpeg lib:" ${TURBOJPEG_LIB})
shun-iwasawa 31accf
shun-iwasawa 31accf
        if (WITH_CANON)
shun-iwasawa 31accf
            set(CANON_LIB ${SDKROOT}/canon/Framework/EDSDK.framework)
shun-iwasawa 31accf
        endif()
shun-iwasawa 31accf
    endif()
shun-iwasawa 31accf
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
Rozhuk Ivan ac51ab
    if(NOT BUILD_TARGET_BSD)
Rozhuk Ivan ac51ab
        find_package(TIFF REQUIRED)
Rozhuk Ivan ac51ab
    endif()
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
rim 26a2b2
    find_library(PTHREAD_LIBRARY pthread)
rim 26a2b2
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)
shun-iwasawa 31accf
    
shun-iwasawa 31accf
    if(PLATFORM EQUAL 64)
shun-iwasawa 31accf
        find_library(TURBOJPEG_LIB turbojpeg)
shun-iwasawa 31accf
        message("**************** turbojpeg lib:" ${TURBOJPEG_LIB})
shun-iwasawa 31accf
    endif()
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
shun-iwasawa 31accf
            boost/boost_1_75_0/
shun-iwasawa 31accf
            boost/boost_1_74_0/
shun-iwasawa 31accf
            boost/boost_1_73_0/
shun-iwasawa 31accf
            boost/boost_1_72_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
shun-iwasawa 31accf
if(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
shun-iwasawa 799a29
if(WITH_TRANSLATION)
shun-iwasawa 799a29
    # generate Qt translations and messages
shun-iwasawa 799a29
    set(LANGUAGES japanese italian french spanish chinese german russian korean czech)
shun-iwasawa 799a29
shun-iwasawa 799a29
    function(add_translation module)
shun-iwasawa 799a29
        set(translation)
shun-iwasawa 799a29
        foreach(lang ${LANGUAGES})
shun-iwasawa 799a29
            set(name "${CMAKE_SOURCE_DIR}/translations/${lang}/${module}.ts")
shun-iwasawa 799a29
            list(APPEND translation ${name})
shun-iwasawa 799a29
            set_source_files_properties(${name} PROPERTIES
shun-iwasawa 799a29
                OUTPUT_LOCATION "${CMAKE_BINARY_DIR}/loc/${lang}"
shun-iwasawa 799a29
            )
shun-iwasawa 799a29
        endforeach()
shun-iwasawa 799a29
shun-iwasawa 799a29
        qt5_create_translation(message ${translation} ${ARGN})
shun-iwasawa 799a29
shun-iwasawa 799a29
        add_custom_target("translation_${module}" DEPENDS ${message})
shun-iwasawa 799a29
        set_target_properties("translation_${module}" PROPERTIES
shun-iwasawa 799a29
            EXCLUDE_FROM_DEFAULT_BUILD TRUE
Campbell Barton 9ece9c
        )
shun-iwasawa 799a29
    endfunction()
shun-iwasawa 799a29
endif()
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()