|
| 1 | +# *********************************************************************** |
| 2 | +# Copyright (c) 2017 Unity Technologies. All rights reserved. |
| 3 | +# |
| 4 | +# Licensed under the ##LICENSENAME##. |
| 5 | +# See LICENSE.md file in the project root for full license information. |
| 6 | +# *********************************************************************** |
| 7 | + |
| 8 | +cmake_minimum_required (VERSION 3.8) |
| 9 | + |
| 10 | +# Default is a release build. |
| 11 | +if (NOT CMAKE_BUILD_TYPE) |
| 12 | + # CMAKE_BUILD_TYPE is special, so we have to CACHE FORCE to actually set it, |
| 13 | + # or else our 'set' has very wonky scope. |
| 14 | + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) |
| 15 | +elseif (CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 16 | + list(APPEND CMAKE_CXX_FLAGS "-DMEMORY_DEBUG") |
| 17 | +endif() |
| 18 | +message(STATUS "Building for ${CMAKE_BUILD_TYPE}") |
| 19 | + |
| 20 | +# has to be done before project is set, or else CMAKE_INSTALL_PREFIX will already be set to a default value |
| 21 | +SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Install path prefix") |
| 22 | +MESSAGE(STATUS "CMAKE_INSTALL_PREFIX is: " ${CMAKE_INSTALL_PREFIX}) |
| 23 | + |
| 24 | +if (NOT DEFINED PACKAGE_VERSION) |
| 25 | + set(PACKAGE_VERSION "0.0.10a") |
| 26 | +endif() |
| 27 | + |
| 28 | +if (NOT DEFINED PACKAGE_PATH) |
| 29 | + set(PACKAGE_PATH "${CMAKE_BINARY_DIR}/FbxExporters_${PACKAGE_VERSION}.unitypackage") |
| 30 | +endif() |
| 31 | + |
| 32 | +if (NOT DEFINED FBXSDK_PACKAGE_PATH) |
| 33 | + # TODO: store the FbxSdk directly in this project |
| 34 | + set(FBXSDK_PACKAGE_PATH "${CMAKE_SOURCE_DIR}/../FbxSharpBuild/FbxSdk_${PACKAGE_VERSION}.unitypackage") |
| 35 | +endif() |
| 36 | + |
| 37 | +project (UnityFbxExporter) |
| 38 | + |
| 39 | +# promote warnings to errors |
| 40 | +if(MSVC) |
| 41 | +set(PROJECT_COMPILE_FLAGS "/WX") |
| 42 | +else() |
| 43 | +# requires gcc 6 or higher |
| 44 | +set(PROJECT_COMPILE_FLAGS "-Werror -Wno-error=null-dereference") |
| 45 | +endif() |
| 46 | + |
| 47 | +add_definitions(${PROJECT_COMPILE_FLAGS}) |
| 48 | + |
| 49 | +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/deps/cmake) |
| 50 | + |
| 51 | +########################################################################### |
| 52 | +# Find packages that we need. |
| 53 | + |
| 54 | +find_package(Unity REQUIRED) |
| 55 | + |
| 56 | +set(Python_ADDITIONAL_VERSIONS 2.7) |
| 57 | + |
| 58 | +########################################################################### |
| 59 | +# Import FbxSharp package |
| 60 | + |
| 61 | +set(FBXSDK_PACKAGE_TARGET import_fbxsdk) |
| 62 | +add_custom_target( |
| 63 | + ${FBXSDK_PACKAGE_TARGET} |
| 64 | + COMMAND rmdir /s "${CMAKE_SOURCE_DIR}/Assets/FbxSdk" |
| 65 | + COMMAND "${UNITY_EDITOR_PATH}" -projectPath "${CMAKE_SOURCE_DIR}" -importPackage ${FBXSDK_PACKAGE_PATH} -quit |
| 66 | +) |
| 67 | + |
| 68 | +########################################################################### |
| 69 | +# TODO: Add target to replace the version number in README.txt |
| 70 | + |
| 71 | +########################################################################### |
| 72 | +# Zip integrations folder |
| 73 | +set(MAYA_INTEGRATION_TARGET zip_maya_integration) |
| 74 | +set(MAYA_INTEGRATION_ZIP_NAME "unityoneclick_for_maya.zip") |
| 75 | +add_custom_command(OUTPUT ${MAYA_INTEGRATION_ZIP_NAME} |
| 76 | + COMMAND ${CMAKE_COMMAND} -E tar "cfv" ${CMAKE_SOURCE_DIR}/Assets/FbxExporters/${MAYA_INTEGRATION_ZIP_NAME} --format=zip |
| 77 | + "${CMAKE_SOURCE_DIR}/Assets/Integrations" |
| 78 | +) |
| 79 | +add_custom_target(${MAYA_INTEGRATION_TARGET} DEPENDS ${MAYA_INTEGRATION_ZIP_NAME}) |
| 80 | + |
| 81 | +########################################################################### |
| 82 | +# Add target for creating a package |
| 83 | +# TODO: synthesize the right project depending on configuration. |
| 84 | +# Make install does the right thing in all cases but it's overkill in release. |
| 85 | +add_custom_command( |
| 86 | + OUTPUT ${PACKAGE_PATH} |
| 87 | + COMMAND "${UNITY_EDITOR_PATH}" -batchmode -projectPath ${CMAKE_SOURCE_DIR} -exportPackage Assets/FbxExporters Assets/FbxSdk ${PACKAGE_PATH} -quit |
| 88 | + COMMENT "Creating Unity Package ${PACKAGE_PATH}" |
| 89 | + DEPENDS ${MAYA_INTEGRATION_TARGET} |
| 90 | + ) |
| 91 | +add_custom_target(unitypackage ALL DEPENDS ${PACKAGE_PATH} ${FBXSDK_PACKAGE_TARGET}) |
| 92 | + |
| 93 | +enable_testing() |
| 94 | +add_test(NAME run-all COMMAND "${UNITY_EDITOR_PATH}" -batchmode -projectPath ${CMAKE_SOURCE_DIR} runEditorTests -quit) |
0 commit comments