From 22fd3b044723cf42e842e090150d532d53f120e7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Jun 16 2016 04:52:02 +0000 Subject: CMake: changes needed to build on Linux (#452) Note that these are the main changes from the linux port. Not a fully working linux port. --- diff --git a/toonz/sources/CMakeLists.txt b/toonz/sources/CMakeLists.txt index 7e7ae24..dd4bc92 100644 --- a/toonz/sources/CMakeLists.txt +++ b/toonz/sources/CMakeLists.txt @@ -6,7 +6,7 @@ message("SDK Root:" ${SDKROOT}) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake") if(APPLE) set(THIRDPARTY_LIBS_HINTS "/usr/local/Cellar/" "/opt/include" ${SDKROOT}) -elseif(WIN32) +elseif(WIN32 OR UNIX) set(THIRDPARTY_LIBS_HINTS ${SDKROOT}) endif() @@ -56,8 +56,29 @@ elseif(APPLE) else() message(FATAL_ERROR "Invalid PLATFORM:" ${PLATFORM} ". 'PLATFORM' must be 32 or 64.") endif() +elseif(UNIX) + # Needed for correct Qt detection + cmake_minimum_required(VERSION 2.8.12) + + message("Unix System") + if(CMAKE_SIZEOF_VOID_P MATCHES "8") + set(PLATFORM 64) + else() + set(PLATFORM 32) + endif() + if (CMAKE_SYSTEM_NAME MATCHES "Linux") + add_definitions(-DLINUX) + else() + message(WARNING "Support for generic Unix (Not Apple or Linux) isn't yet working!") + endif() + + set(CMAKE_CXX_STANDARD 11) + + find_package(Qt5Widgets) + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -lstdc++ -std=c++11") else() - message("Unknown System") + message(ERROR "Unknown System") endif() add_definitions(-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED) @@ -109,10 +130,10 @@ macro(_find_toonz_library OUT_LIB_LIST IN_LIB_LIST) foreach(arg ${IN_LIB_LIST}) unset(COREPATH CACHE) # find しても cmake が走るときにはできていないので完全なパス名を生成して返すだけ - if(WIN32) - set(LIBPATH ${arg}) - else() + if(APPLE) set(LIBPATH ${CMAKE_CURRENT_BINARY_DIR}/../${arg}/lib${arg}${CMAKE_SHARED_LIBRARY_SUFFIX}) + else() + set(LIBPATH ${arg}) endif() set(OUTLIST ${OUTLIST} ${LIBPATH}) endforeach() @@ -152,7 +173,7 @@ if(WIN32) if(PLATFORM EQUAL 32) set(QT_LIB ${SDKROOT}/quicktime/QT73SDK/Libraries/QTMLClient.lib) endif() -else() +elseif(APPLE) find_library(GLUT_LIB GLUT) find_library(GL_LIB OpenGL) find_library(Z_LIB z) @@ -198,13 +219,64 @@ else() find_package(LZO REQUIRED) message("LZO:" ${LZO_INCLUDE_DIR}) + +elseif(UNIX) + find_library(GL_LIB GL) + find_library(GLU_LIB GLU) + find_library(GLUT_LIB glut) + find_library(Z_LIB z) + + find_package(TIFF REQUIRED) + set(TIFF_LIB ${TIFF_LIBRARY}) + find_package(PNG REQUIRED) + set(PNG_LIB ${PNG_LIBRARY}) + message("******* libpng:" ${PNG_LIB}) + find_package(GLEW) + + find_package(SuperLU REQUIRED) + set(SUPERLU_INCLUDE_DIR ${SUPERLU_INCLUDE_DIR}/superlu) + set(SUPERLU_LIB ${SUPERLU_LIBRARY}) + + 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) + + # TODO: check for them properly in some sane order with pkg-config + find_library(OPENBLAS_LIB NAMES cblas gslcblas openblas blas) + message("OpenBLAS:" ${OPENBLAS_LIB}) + + set(JPEG_LIB ${JPEG_LIBRARY}) + set(LZ4_LIB ${LZ4_LIB_LDFLAGS}) + + find_package(LZO REQUIRED) + message("LZO:" ${LZO_INCLUDE_DIR}) + + pkg_check_modules(FREETYPE REQUIRED freetype2) + pkg_check_modules(SDL_LIB REQUIRED sdl) endif() include_directories(BEFORE ${TIFF_INCLUDE_DIR} ${PNG_INCLUDE_DIRS}) -find_path(BOOST_ROOT include/boost boost HINTS ${THIRDPARTY_LIBS_HINTS} - PATH_SUFFIXES boost/boost_1_60_0/ boost/boost_1_59_0/ - boost/boost_1_58_0/ boost/boost_1_57_0/ boost/boost_1_56_0/ boost155/1.55.0_1/ boost/boost_1_55_0/ ) +if(WIN32 OR APPLE) + find_path(BOOST_ROOT include/boost boost HINTS ${THIRDPARTY_LIBS_HINTS} + PATH_SUFFIXES boost/boost_1_60_0/ boost/boost_1_59_0/ + boost/boost_1_58_0/ boost/boost_1_57_0/ boost/boost_1_56_0/ boost155/1.55.0_1/ boost/boost_1_55_0/ ) +endif() find_package(Boost 1.55 REQUIRED) include_directories(${Boost_INCLUDE_DIR} ${LZ4_LIB_INCLUDE_DIRS} ${USB_LIB_INCLUDE_DIRS} ${SUPERLU_INCLUDE_DIR} ${JPEG_INCLUDE_DIR}) @@ -217,6 +289,10 @@ if(WIN32) # place Toonz.exe and dlls in the same directory set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") +elseif(APPLE) + # pass +elseif(UNIX) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) endif() if(MSVC AND MSVC_VERSION EQUAL 1800) @@ -263,7 +339,7 @@ add_subdirectory(tcleanupper) add_subdirectory(tcomposer) add_subdirectory(tconverter) add_subdirectory(toonzfarm) -if(PLATFORM EQUAL 32) +if((PLATFORM EQUAL 32) AND (WIN32 OR APPLE)) add_subdirectory(t32bitsrv) endif() diff --git a/toonz/sources/image/CMakeLists.txt b/toonz/sources/image/CMakeLists.txt index f73ec7d..cfb5653 100644 --- a/toonz/sources/image/CMakeLists.txt +++ b/toonz/sources/image/CMakeLists.txt @@ -64,6 +64,13 @@ else() set(SOURCES ${SOURCES} mov/tiio_movM.cpp 3gp/tiio_3gpM.cpp) +elseif(UNIX) + set(HEADERS ${HEADERS} + 3gp/tiio_3gp_proxy.h + mov/tiio_mov_proxy.h) + set(SOURCES ${SOURCES} + mov/tiio_mov_proxy.cpp + 3gp/tiio_3gp_proxy.cpp) endif() add_library(image SHARED ${HEADERS} ${SOURCES}) @@ -95,7 +102,7 @@ if(WIN32) set(EXTRA_LIBS ${TNZLIBS} vfw32.lib) -else() +elseif(APPLE) if(PLATFORM EQUAL 32) find_library(CORE_SERVICES_LIB CoreServices) set(OSX_10_6_SDK_PATH "") @@ -113,6 +120,10 @@ else() ${CARBON_LIB} ${CORE_SERVICES_LIB} ${QD_LIB}) +else() + # Generic Unix + set(EXTRA_LIBS + ${TNZLIBS}) endif() target_link_libraries(image Qt5::Core Qt5::Network ${Z_LIB} ${GLUT_LIB} ${GL_LIB} ${JPEG_LIB} ${TIFF_LIB} ${PNG_LIB} ${EXTRA_LIBS}) diff --git a/toonz/sources/tnzbase/CMakeLists.txt b/toonz/sources/tnzbase/CMakeLists.txt index 2133715..2bd9710 100644 --- a/toonz/sources/tnzbase/CMakeLists.txt +++ b/toonz/sources/tnzbase/CMakeLists.txt @@ -134,11 +134,16 @@ if(WIN32) ../common/twain/ttwain_stateW.c ../common/twain/ttwain_utilW.c ../common/twain/ttwain_winW.c) -else() +elseif(APPLE) set(OBJCSOURCES ${OBJCSOURCES} ../common/twain/ttwain_stateM.c ../common/twain/ttwain_utilM.c ../common/twain/ttwain_winM.c) +elseif(UNIX) + set(OBJCSOURCES ${OBJCSOURCES} + ../common/twain/ttwain_stateX.c + ../common/twain/ttwain_utilX.c + ../common/twain/ttwain_winX.c) endif() if(APPLE) @@ -167,7 +172,7 @@ include_directories(../common/flash ${SDKROOT}/libusb/libusb-1.0.9/include) if(WIN32) set(EXTRA_LIBS tnzcore) -else() +elseif(APPLE) find_library(TWAIN_LIB TWAIN) find_library(IOKIT_LIB IOKit) find_library(COCOA_LIB Cocoa) @@ -180,6 +185,12 @@ else() ${COCOA_LIB}) target_link_libraries(tnzbase Qt5::Core Qt5::Gui) +elseif(UNIX) + _find_toonz_library(EXTRA_LIBS "tnzcore") + set(EXTRA_LIBS ${EXTRA_LIBS} + ${SDL_LIB_LIBRARIES}) + + target_link_libraries(tnzbase Qt5::Core Qt5::Gui) endif() target_link_libraries(tnzbase Qt5::Core Qt5::Gui ${EXTRA_LIBS}) diff --git a/toonz/sources/tnzcore/CMakeLists.txt b/toonz/sources/tnzcore/CMakeLists.txt index 6adfd51..e0ca640 100644 --- a/toonz/sources/tnzcore/CMakeLists.txt +++ b/toonz/sources/tnzcore/CMakeLists.txt @@ -246,10 +246,20 @@ if(WIN32) set(SOURCES ${SOURCES} ../common/tsound/tsound_nt.cpp ../common/tvrender/tfont_nt.cpp) -else() +elseif(APPLE) set(SOURCES ${SOURCES} ../common/tsound/tsound_mac.cpp ../common/tvrender/tfont_mac.cpp) +elseif(UNIX) + set(SOURCES ${SOURCES} + ../common/tvrender/tfont_qt.cpp) + if(SDL_LIB_FOUND) + set(SOURCES ${SOURCES} + ../common/tsound/tsound_sdl.cpp) + else() + set(SOURCES ${SOURCES} + ../common/tsound/tsound_x.cpp) + endif() endif() add_translation(tnzcore ${HEADERS} ${SOURCES}) @@ -281,7 +291,7 @@ if(WIN32) winmm.lib opengl32.lib glu32.lib) -else() +elseif(APPLE) find_library(AUDIOUNIT_LIB AudioUnit) find_library(AUDIOTB_LIB AudioToolbox) find_library(CARBON_LIB Carbon) @@ -290,6 +300,11 @@ else() ${AUDIOUNIT_LIB} ${AUDIOTB_LIB} ${CARBON_LIB}) +elseif(UNIX) + set(QT_LIB) # avoid warning + include_directories(${FREETYPE_INCLUDE_DIRS}) + set(EXTRA_LIBS + ${GLU_LIB}) endif() target_link_libraries(tnzcore diff --git a/toonz/sources/tnzext/CMakeLists.txt b/toonz/sources/tnzext/CMakeLists.txt index 2bc4abb..0e5b056 100644 --- a/toonz/sources/tnzext/CMakeLists.txt +++ b/toonz/sources/tnzext/CMakeLists.txt @@ -94,7 +94,7 @@ if(WIN32) Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Network ${GLUT_LIB} ${GL_LIB} ${SUPERLU_LIB} ${OPENBLAS_LIB} ${EXTRA_LIBS} tnzcore tnzbase) -else() +elseif(APPLE) set(EXTRA_LIBS ${CMAKE_CURRENT_BINARY_DIR}/../tnzcore/libtnzcore.dylib ${CMAKE_CURRENT_BINARY_DIR}/../tnzbase/libtnzbase.dylib) @@ -102,4 +102,12 @@ else() target_link_libraries(tnzext Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Network ${ACCE_LIB} ${GLUT_LIB} ${GL_LIB} ${SUPERLU_LIB} ${EXTRA_LIBS}) +elseif(UNIX) + _find_toonz_library(EXTRA_LIBS "tnzcore;tnzbase") + + set(EXTRA_LIBS ${EXTRA_LIBS} ${OPENBLAS_LIB}) + + target_link_libraries(tnzext + Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Network + ${GLUT_LIB} ${GL_LIB} ${SUPERLU_LIB} ${EXTRA_LIBS}) endif() diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txt index 0a759d6..1ce1b80 100644 --- a/toonz/sources/toonz/CMakeLists.txt +++ b/toonz/sources/toonz/CMakeLists.txt @@ -352,7 +352,7 @@ if(WIN32) Qt5::WinMain Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Xml Qt5::Script Qt5::Widgets Qt5::PrintSupport ${GL_LIB} ${GLUT_LIB} tnzcore tnzbase toonzlib colorfx tnzext image sound toonzqt tnztools tnzstdfx tfarm) -else() +elseif(APPLE) find_library(COCOA_LIB Cocoa) _find_toonz_library(EXTRA_LIBS "tnzcore;tnzbase;toonzlib;colorfx;tnzext;image;sound;toonzqt;tnztools") @@ -361,7 +361,15 @@ else() set(EXTRA_LIBS ${EXTRA_LIBS} "$" "$") target_link_libraries(OpenToonz_${VERSION} Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Xml Qt5::Script Qt5::Widgets Qt5::PrintSupport ${GL_LIB} ${GLUT_LIB} ${COCOA_LIB} ${EXTRA_LIBS}) +elseif(UNIX) + _find_toonz_library(EXTRA_LIBS "tnzcore;tnzbase;toonzlib;colorfx;tnzext;image;sound;toonzqt;tnztools") + + # 変なところにライブラリ生成するカスども + set(EXTRA_LIBS ${EXTRA_LIBS} "$" "$") + + set(EXTRA_LIBS ${EXTRA_LIBS} ${Boost_LIBRARIES} ${OPENBLAS_LIB}) + target_link_libraries(OpenToonz_${VERSION} Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Xml Qt5::Script Qt5::Widgets Qt5::PrintSupport ${GL_LIB} ${GLUT_LIB} ${GLU_LIB} ${EXTRA_LIBS}) endif() if(APPLE) diff --git a/toonz/sources/toonzfarm/tfarm/CMakeLists.txt b/toonz/sources/toonzfarm/tfarm/CMakeLists.txt index d7205b3..f181f5c 100644 --- a/toonz/sources/toonzfarm/tfarm/CMakeLists.txt +++ b/toonz/sources/toonzfarm/tfarm/CMakeLists.txt @@ -35,11 +35,13 @@ if(WIN32) set(EXTRA_LIBS tnzcore tnzbase toonzlib ws2_32.lib) -else() +elseif(APPLE) set(EXTRA_LIBS ${CMAKE_CURRENT_BINARY_DIR}/../../tnzcore/libtnzcore.dylib ${CMAKE_CURRENT_BINARY_DIR}/../../tnzbase/libtnzbase.dylib ${CMAKE_CURRENT_BINARY_DIR}/../../toonzlib/libtoonzlib.dylib) +elseif(UNIX) + _find_toonz_library(EXTRA_LIBS "tnzcore;tnzbase;toonzlib;tnzext") endif() target_link_libraries(tfarm diff --git a/toonz/sources/toonzlib/CMakeLists.txt b/toonz/sources/toonzlib/CMakeLists.txt index 177088d..74bd6c8 100644 --- a/toonz/sources/toonzlib/CMakeLists.txt +++ b/toonz/sources/toonzlib/CMakeLists.txt @@ -339,7 +339,7 @@ if(WIN32) Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Script ${GLUT_LIB} ${GL_LIB} vfw32.lib tnzcore tnzbase tnzext) -else() +elseif(APPLE) set(EXTRA_LIBS ${CMAKE_CURRENT_BINARY_DIR}/../tnzcore/libtnzcore.dylib ${CMAKE_CURRENT_BINARY_DIR}/../tnzbase/libtnzbase.dylib @@ -347,4 +347,8 @@ else() ${USB_LIB}) target_link_libraries(toonzlib Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Script ${GLUT_LIB} ${GL_LIB} ${EXTRA_LIBS}) +elseif(UNIX) + _find_toonz_library(EXTRA_LIBS "tnzcore;tnzbase;tnzext") + + target_link_libraries(toonzlib Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Script ${GLUT_LIB} ${GL_LIB} ${EXTRA_LIBS}) endif()