Skip to content

Commit 14f9c7d

Browse files
committed
add cmake files to create package + compile cs
1 parent 0965581 commit 14f9c7d

File tree

5 files changed

+429
-0
lines changed

5 files changed

+429
-0
lines changed

CMakeLists.txt

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
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+
if (NOT DEFINED PACKAGE_VERSION OR "${PACKAGE_VERSION}" STREQUAL "")
21+
set(PACKAGE_VERSION "0.0.15a")
22+
endif()
23+
message(STATUS "Using Package Version: ${PACKAGE_VERSION}")
24+
25+
if (NOT DEFINED PACKAGE_PATH OR "${PACKAGE_PATH}" STREQUAL "")
26+
set(PACKAGE_PATH "${CMAKE_BINARY_DIR}/FbxExporters_${PACKAGE_VERSION}.unitypackage")
27+
endif()
28+
message(STATUS "Creating Exporter Package at: ${PACKAGE_PATH}")
29+
30+
if (NOT DEFINED FBXSDK_PACKAGE_PATH)
31+
# TODO: store the FbxSdk directly in this project
32+
set(FBXSDK_PACKAGE_PATH "${CMAKE_SOURCE_DIR}/../FbxSharpBuild")
33+
34+
# find the most recent package at the path
35+
file(GLOB FBXSDK_PACKAGES "${FBXSDK_PACKAGE_PATH}/FbxSdk_*.*.*.unitypackage")
36+
set(NEWEST_PACKAGE "")
37+
foreach(fbxsdk_package ${FBXSDK_PACKAGES})
38+
if(fbxsdk_package IS_NEWER_THAN NEWEST_PACKAGE)
39+
set(NEWEST_PACKAGE ${fbxsdk_package})
40+
endif()
41+
endforeach(fbxsdk_package)
42+
43+
if("${NEWEST_PACKAGE}" STREQUAL "")
44+
message(FATAL_ERROR "Failed to find FbxSdk Unity Package at: ${FBXSDK_PACKAGE_PATH}")
45+
else()
46+
set(FBXSDK_PACKAGE_PATH ${NEWEST_PACKAGE})
47+
endif()
48+
endif()
49+
50+
IF(EXISTS ${FBXSDK_PACKAGE_PATH})
51+
message(STATUS "Using FbxSdk Package: ${FBXSDK_PACKAGE_PATH}")
52+
ELSE()
53+
message(FATAL_ERROR "Cannot find FbxSdk Package: ${FBXSDK_PACKAGE_PATH}")
54+
ENDIF()
55+
56+
# promote warnings to errors
57+
if(MSVC)
58+
set(PROJECT_COMPILE_FLAGS "/WX")
59+
else()
60+
# requires gcc 6 or higher
61+
set(PROJECT_COMPILE_FLAGS "-Werror -Wno-error=null-dereference")
62+
endif()
63+
64+
add_definitions(${PROJECT_COMPILE_FLAGS})
65+
66+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/deps/cmake)
67+
68+
###########################################################################
69+
# Find packages that we need.
70+
71+
find_package(Unity REQUIRED)
72+
find_package(CSharpAssemblies REQUIRED)
73+
include(deps/cmake/BuildCSharp.cmake)
74+
75+
set(Python_ADDITIONAL_VERSIONS 2.7)
76+
77+
###########################################################################
78+
# Import FbxSharp package
79+
80+
set(FBXSDK_PACKAGE_TARGET import_fbxsdk)
81+
add_custom_target(
82+
${FBXSDK_PACKAGE_TARGET}
83+
# remove FbxSdk folder
84+
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_SOURCE_DIR}/Assets/FbxExporters/FbxSdk"
85+
COMMAND "${UNITY_EDITOR_PATH}" -projectPath "${CMAKE_SOURCE_DIR}" -importPackage ${FBXSDK_PACKAGE_PATH} -quit
86+
COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_SOURCE_DIR}/Assets/FbxSdk" "${CMAKE_SOURCE_DIR}/Assets/FbxExporters/FbxSdk"
87+
)
88+
89+
###########################################################################
90+
# Add target to replace the unity package version number in files
91+
set(README_TARGET readme_replace)
92+
add_custom_target(
93+
${README_TARGET}
94+
COMMAND ${PYTHON_EXECUTABLE}
95+
"${CMAKE_SOURCE_DIR}/scripts/file-search-replace.py"
96+
"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/README.txt"
97+
".*VERSION.*:.*"
98+
"VERSION: ${PACKAGE_VERSION}"
99+
COMMAND ${PYTHON_EXECUTABLE}
100+
"${CMAKE_SOURCE_DIR}/scripts/file-search-replace.py"
101+
"${CMAKE_SOURCE_DIR}/Assets/Integrations/Autodesk/maya/scripts/unityOneClick/version.py"
102+
".*VERSION.*=.*"
103+
"VERSION = '${PACKAGE_VERSION}'"
104+
DEPENDS "${CMAKE_SOURCE_DIR}/scripts/file-search-replace.py"
105+
COMMENT "Replacing version number in files"
106+
)
107+
108+
###########################################################################
109+
# Compile editor scripts into a multi-platform DLL
110+
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
111+
set(CLASS_LIBRARY_DEST "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
112+
set(CLASS_LIBRARY_NAME "UnityFbxExporter.dll")
113+
114+
add_custom_command(OUTPUT ${CLASS_LIBRARY_DEST}
115+
COMMAND ${CMAKE_COMMAND} -E make_directory ${CLASS_LIBRARY_DEST}
116+
)
117+
118+
fbxexporters_compile_csharp(OUTPUT ${CLASS_LIBRARY_DEST}/${CLASS_LIBRARY_NAME}
119+
EXTRA_ARGS
120+
"/target:library"
121+
SOURCES
122+
"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/FbxPrefab.cs"
123+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/ConvertToModel.cs"
124+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/FbxExporter.cs"
125+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/FbxExportSettings.cs"
126+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/FbxPrefabAutoUpdater.cs"
127+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/FbxPrefabInspector.cs"
128+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/InstallIntegration.cs"
129+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/ReviewLastSavedModel.cs"
130+
REFERENCES
131+
"${CSHARP_MSCORLIB_LIBRARY}"
132+
"${CSHARP_SYSTEM_CORE_LIBRARY}"
133+
"${CSHARP_SYSTEM_LIBRARY}"
134+
"${CSHARP_UNITYEDITOR_LIBRARY}"
135+
"${CSHARP_UNITYENGINE_LIBRARY}"
136+
"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/FbxSdk/Plugins/UnityFbxSdk.dll"
137+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/FbxTurnTableBase.cs"
138+
DEPENDS
139+
"${CLASS_LIBRARY_DEST}"
140+
)
141+
add_custom_target(UnityFbxExporterDLL ALL DEPENDS ${CLASS_LIBRARY_DEST}/${CLASS_LIBRARY_NAME})
142+
143+
144+
#set(CLASS_LIBRARY_NAME_3 "UnityFbxExporterSettings.dll")
145+
#fbxexporters_compile_csharp(OUTPUT ${CLASS_LIBRARY_DEST}/${CLASS_LIBRARY_NAME_3}
146+
# EXTRA_ARGS
147+
# "/target:library"
148+
# SOURCES
149+
# "${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/FbxExportSettings.cs"
150+
# REFERENCES
151+
# "${CSHARP_MSCORLIB_LIBRARY}"
152+
# "${CSHARP_SYSTEM_CORE_LIBRARY}"
153+
# "${CSHARP_SYSTEM_LIBRARY}"
154+
# "${CSHARP_UNITYEDITOR_LIBRARY}"
155+
# "${CSHARP_UNITYENGINE_LIBRARY}"
156+
# "${CMAKE_SOURCE_DIR}/Assets/FbxExporters/FbxSdk/Plugins/UnityFbxSdk.dll"
157+
# DEPENDS
158+
# "${CLASS_LIBRARY_DEST}"
159+
#)
160+
#add_custom_target(UnityFbxSettingsDLL ALL DEPENDS ${CLASS_LIBRARY_DEST}/${CLASS_LIBRARY_NAME_3})
161+
162+
set(CLASS_LIBRARY_NAME_2 "UnityFbxExporterEditor.dll")
163+
fbxexporters_compile_csharp(OUTPUT ${CLASS_LIBRARY_DEST}/${CLASS_LIBRARY_NAME_2}
164+
EXTRA_ARGS
165+
"/target:library"
166+
SOURCES
167+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/*.cs"
168+
"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/ConvertToModel.cs"
169+
"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/FbxExporter.cs"
170+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/FbxExportSettings.cs"
171+
"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/FbxPrefabAutoUpdater.cs"
172+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/FbxPrefabInspector.cs"
173+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/InstallIntegration.cs"
174+
#"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/Editor/ReviewLastSavedModel.cs"
175+
REFERENCES
176+
"${CSHARP_MSCORLIB_LIBRARY}"
177+
"${CSHARP_SYSTEM_CORE_LIBRARY}"
178+
"${CSHARP_SYSTEM_LIBRARY}"
179+
"${CSHARP_UNITYEDITOR_LIBRARY}"
180+
"${CSHARP_UNITYENGINE_LIBRARY}"
181+
"${CMAKE_SOURCE_DIR}/Assets/FbxExporters/FbxSdk/Plugins/UnityFbxSdk.dll"
182+
"${CLASS_LIBRARY_DEST}/${CLASS_LIBRARY_NAME}"
183+
DEPENDS
184+
"${CLASS_LIBRARY_DEST}"
185+
UnityFbxExporterDLL
186+
)
187+
add_custom_target(UnityFbxExporterEditorDLL ALL DEPENDS ${CLASS_LIBRARY_DEST}/${CLASS_LIBRARY_NAME_2})
188+
189+
endif()
190+
191+
###########################################################################
192+
# Add target for creating a package
193+
add_custom_command(
194+
OUTPUT ${PACKAGE_PATH}
195+
COMMAND "${UNITY_EDITOR_PATH}" -batchmode -projectPath ${CMAKE_SOURCE_DIR} -exportPackage Assets/FbxExporters ${PACKAGE_PATH} -quit
196+
COMMENT "Creating Unity Package ${PACKAGE_PATH}"
197+
DEPENDS ${MAYA_INTEGRATION_TARGET}
198+
)
199+
add_custom_target(unitypackage DEPENDS ${PACKAGE_PATH} ${FBXSDK_PACKAGE_TARGET} ${MAYA_INTEGRATION_TARGET} ${README_TARGET})
200+
201+
enable_testing()
202+
add_test(NAME run-all COMMAND "${UNITY_EDITOR_PATH}" -batchmode -projectPath ${CMAKE_SOURCE_DIR} runEditorTests -quit)

deps/cmake/BuildCSharp.cmake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
find_package(CSharpAssemblies REQUIRED)
2+
3+
macro(FBXEXPORTERS_COMPILE_CSHARP)
4+
cmake_parse_arguments(_csharpCompile
5+
""
6+
"OUTPUT"
7+
"SOURCES;REFERENCES;DEPENDS;EXTRA_ARGS"
8+
${ARGN})
9+
10+
string(CONCAT _csharpCompile_compiler $<$<PLATFORM_ID:"Darwin">:"${MONO_COMPILER} "> "${CSHARP_COMPILER}")
11+
12+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
13+
set(_csharpCompile_warnings="/nowarn:1701,1702,2008")
14+
else()
15+
set(_csharpCompile_warnings="/nowarn:1701,1702")
16+
endif()
17+
18+
file(TO_NATIVE_PATH "${_csharpCompile_SOURCES}" _csharpCompile_SOURCES)
19+
20+
foreach(_csharpCompileRef ${_csharpCompile_REFERENCES})
21+
list(APPEND _csharpCompile_REFERENCE_ARGS "/reference:${_csharpCompileRef}")
22+
endforeach()
23+
24+
add_custom_command(OUTPUT ${_csharpCompile_OUTPUT}
25+
COMMAND "${_csharpCompile_compiler}"
26+
/noconfig
27+
/langversion:4
28+
/nostdlib+
29+
/warn:4
30+
${_csharpCompile_warnings}
31+
/optimize+
32+
/out:${_csharpCompile_OUTPUT}
33+
${_csharpCompile_EXTRA_ARGS}
34+
${_csharpCompile_REFERENCE_ARGS}
35+
${_csharpCompile_SOURCES}
36+
DEPENDS ${_csharpCompile_DEPENDS})
37+
endmacro()

deps/cmake/FindCSharpAssemblies.cmake

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
# We need to have Unity available to compile against it.
9+
find_package(Unity REQUIRED)
10+
11+
# The list of .NET versions to look for.
12+
# The first of these is the most-preferred.
13+
set(NET_COMPILER_VERSIONS "4.5" "4.0.30319" "4.0")
14+
set(NET_REFERENCE_ASSEMBLIES_VERSIONS "3.5" "2.0")
15+
set(NET_LIB_VERSIONS "2.0.50727" "2.0")
16+
17+
# Platform-specific code.
18+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
19+
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
20+
21+
# MONO_ROOT_PATH is from FindUnity (on Darwin)
22+
list(APPEND CSHARP_COMPILER_PATHS "${MONO_ROOT_PATH}/bin")
23+
foreach(VERSION ${NET_REFERENCE_ASSEMBLIES_VERSIONS})
24+
list(APPEND CSHARP_DLL_PATHS "${MONO_ROOT_PATH}/lib/mono/${VERSION}")
25+
list(APPEND REFERENCE_ASSEMBLIES_PATHS "${MONO_ROOT_PATH}/lib/mono/${VERSION}")
26+
endforeach()
27+
28+
find_program(MONO_COMPILER mono PATH ${CSHARP_COMPILER_PATH} NO_DEFAULT_PATH)
29+
find_program(MONO_COMPILER mono PATH ${CSHARP_COMPILER_PATH})
30+
31+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
32+
message("Using .Net versions ${NET_COMPILER_VERSIONS}")
33+
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
34+
35+
set(DOT_NET_PATH "C:/Windows/Microsoft.NET/Framework")
36+
set(REFERENCE_ASSEMBLIES_PATH "C:/Program Files \(x86\)/Reference Assemblies/Microsoft/Framework")
37+
38+
foreach(VERSION ${NET_COMPILER_VERSIONS})
39+
list(APPEND CSHARP_COMPILER_PATHS "${DOT_NET_PATH}/v${VERSION}")
40+
endforeach()
41+
42+
foreach(VERSION ${NET_REFERENCE_ASSEMBLIES_VERSIONS})
43+
list(APPEND REFERENCE_ASSEMBLIES_PATHS "${REFERENCE_ASSEMBLIES_PATH}/v${VERSION}")
44+
endforeach()
45+
46+
foreach(VERSION ${NET_LIB_VERSIONS})
47+
list(APPEND CSHARP_DLL_PATHS "${DOT_NET_PATH}/v${VERSION}")
48+
endforeach()
49+
50+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
51+
message(WARNING "Linux: Not Implemented")
52+
endif()
53+
54+
message("Looking for C# compiler in ${CSHARP_COMPILER_PATHS}")
55+
find_program(CSHARP_COMPILER mcs csc PATHS ${CSHARP_COMPILER_PATHS} NO_DEFAULT_PATH)
56+
find_program(CSHARP_COMPILER mcs csc PATHS ${CSHARP_COMPILER_PATHS})
57+
message("Found: ${CSHARP_COMPILER}\n")
58+
59+
message("Looking for mscorlib.dll in ${CSHARP_DLL_PATHS}")
60+
find_library(CSHARP_MSCORLIB_LIBRARY mscorlib.dll PATHS ${CSHARP_DLL_PATHS} NO_DEFAULT_PATH)
61+
find_library(CSHARP_MSCORLIB_LIBRARY mscorlib.dll PATHS ${CSHARP_DLL_PATHS})
62+
message("Found: ${CSHARP_MSCORLIB_LIBRARY}\n")
63+
64+
message("Looking for System.dll in ${CSHARP_DLL_PATHS}")
65+
find_library(CSHARP_SYSTEM_LIBRARY System.dll PATHS ${CSHARP_DLL_PATHS} NO_DEFAULT_PATH)
66+
find_library(CSHARP_SYSTEM_LIBRARY System.dll PATHS ${CSHARP_DLL_PATHS})
67+
message("Found: ${CSHARP_SYSTEM_LIBRARY}\n")
68+
69+
message("Looking for System.Core.dll in ${REFERENCE_ASSEMBLIES_PATHS}")
70+
find_library(CSHARP_SYSTEM_CORE_LIBRARY System.Core.dll PATHS ${REFERENCE_ASSEMBLIES_PATHS} NO_DEFAULT_PATH)
71+
find_library(CSHARP_SYSTEM_CORE_LIBRARY System.Core.dll PATHS ${REFERENCE_ASSEMBLIES_PATHS})
72+
message("Found: ${CSHARP_SYSTEM_CORE_LIBRARY}\n")
73+
74+
# Standard code to report whether we found the package or not.
75+
#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
76+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CSHARP_ASSEMBLIES DEFAULT_MSG CSHARP_COMPILER CSHARP_MSCORLIB_LIBRARY CSHARP_SYSTEM_LIBRARY CSHARP_SYSTEM_CORE_LIBRARY)

deps/cmake/FindUnity.cmake

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
# Find Unity and set things up to be able to compile Unity.
9+
10+
# If UNITY is set to the root of the Unity install, we use it, otherwise we set
11+
# it to the default install location.
12+
13+
if (NOT DEFINED UNITY)
14+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
15+
set(UNITY "/Applications/Unity")
16+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
17+
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
18+
set(UNITY "c:/Program Files/Unity2017.1.1f1")
19+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
20+
set(UNITY "/opt/Unity")
21+
endif()
22+
endif()
23+
24+
# Be generous about how to interpret UNITY:
25+
# it can be the directory that includes the Unity executable,
26+
# or the root of the Unity installation. On mac it can be the app bundle.
27+
list(APPEND UNITY_EXECUTABLE_PATHS "${UNITY}")
28+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
29+
list(APPEND UNITY_EXECUTABLE_PATHS "${UNITY}/Contents/MacOS")
30+
list(APPEND UNITY_EXECUTABLE_PATHS "${UNITY}/Unity.app/Contents/MacOS")
31+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
32+
list(APPEND UNITY_EXECUTABLE_PATHS "${UNITY}/Editor")
33+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
34+
list(APPEND UNITY_EXECUTABLE_PATHS "${UNITY}/Editor")
35+
endif()
36+
37+
find_program(UNITY_EDITOR_PATH Unity PATHS ${UNITY_EXECUTABLE_PATHS})
38+
39+
if (DEFINED UNITY_EDITOR_DLL_PATH)
40+
message("Using ${UNITY_EDITOR_DLL_PATH}")
41+
else()
42+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
43+
# The editor is Unity.app/Contents/MacOS/Unity
44+
# The dlls are in Unity.app/Contents/Managed/*.dll
45+
# Monodevelop is Monodevelop.app/Contents/
46+
get_filename_component(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_PATH}" PATH)
47+
get_filename_component(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_DLL_PATH}" DIRECTORY)
48+
set(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_DLL_PATH}/Managed")
49+
50+
list(APPEND MONO_ROOT_PATH "${UNITY_EDITOR_DLL_PATH}/../../../Monodevelop.app/Contents/Frameworks/Mono.framework/Versions/Current")
51+
52+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
53+
# The editor is .../Unity.exe
54+
# The dlls are in .../Data/Managed/*.dll
55+
get_filename_component(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_PATH}" PATH)
56+
set(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_DLL_PATH}/Data/Managed")
57+
58+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
59+
# The editor is .../Unity
60+
# The dlls are in .../Data/Managed/*.dll
61+
get_filename_component(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_PATH}" PATH)
62+
set(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_DLL_PATH}/Data/Managed")
63+
endif()
64+
endif()
65+
66+
# Look for a dll on all platforms.
67+
message("Looking for UnityEditor.dll in ${UNITY_EDITOR_DLL_PATH}")
68+
set(_platformLibrarySuffix ${CMAKE_FIND_LIBRARY_SUFFIXES})
69+
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
70+
find_library(CSHARP_UNITYEDITOR_LIBRARY UnityEditor.dll PATH ${UNITY_EDITOR_DLL_PATH})
71+
find_library(CSHARP_UNITYENGINE_LIBRARY UnityEngine.dll PATH ${UNITY_EDITOR_DLL_PATH})
72+
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_platformLibrarySuffix})
73+
74+
# Check whether we found everything we needed.
75+
include(FindPackageHandleStandardArgs)
76+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Unity DEFAULT_MSG UNITY_EDITOR_PATH CSHARP_UNITYEDITOR_LIBRARY)

0 commit comments

Comments
 (0)