Skip to content

Commit dbb3f6f

Browse files
authored
Merge pull request #195 from Unity-Technologies/UNI-22634-bindings-ship-as-binaries
UNI-22634-bindings-ship-as-binaries (part2)
2 parents b87503e + 9af860f commit dbb3f6f

File tree

2 files changed

+89
-22
lines changed

2 files changed

+89
-22
lines changed

CMakeLists.txt

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -225,28 +225,63 @@ set(CLASS_LIBRARY_NAME "FbxSharp.dll")
225225
string( TOLOWER "${CMAKE_BUILD_TYPE}" LOWER_CMAKE_BUILD_TYPE )
226226
if(LOWER_CMAKE_BUILD_TYPE MATCHES release)
227227
string(CONCAT CS_COMPILE_CMD $<$<PLATFORM_ID:"Darwin">:"${MONO_COMPILER} "> "${CSHARP_COMPILER}")
228+
229+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
230+
add_custom_target(
231+
class_library ALL
232+
COMMAND "${CS_COMPILE_CMD}"
233+
/noconfig
234+
/nowarn:1701,1702,2008
235+
/langversion:4
236+
/nostdlib+
237+
/warn:4
238+
/optimize+
239+
/out:${CLASS_LIBRARY_NAME}
240+
/target:library
241+
/reference:\"${CSHARP_MSCORLIB_LIBRARY}\"
242+
/reference:\"${CSHARP_SYSTEM_CORE_LIBRARY}\"
243+
/reference:\"${CSHARP_SYSTEM_LIBRARY}\"
244+
/reference:\"${CSHARP_UNITYEDITOR_LIBRARY}\"
245+
${CMAKE_SOURCE_DIR}/scripts/Properties\\AssemblyInfo.cs
246+
${CMAKE_SOURCE_DIR}/src/optimized\\*.cs
247+
${CMAKE_BINARY_DIR}/swig/generated/csharp\\*.cs
248+
DEPENDS fbxsdk_csharp globals_replace
249+
COMMENT "Building FbxSharp assembly"
250+
WORKING_DIRECTORY ${CLASS_LIBRARY_DEST}
251+
)
252+
else()
253+
FILE(GLOB CSHARP_SOURCES_properties "${CMAKE_SOURCE_DIR}/scripts/Properties/*.cs")
254+
SET(CSHARP_SOURCES ${CSHARP_SOURCES} ${CSHARP_SOURCES_properties})
255+
256+
FILE(GLOB CSHARP_SOURCES_optimized "${CMAKE_SOURCE_DIR}/src/optimized/*.cs")
257+
SET(CSHARP_SOURCES ${CSHARP_SOURCES} ${CSHARP_SOURCES_optimized})
258+
259+
set(CSHARP_GENERATED_SOURCES "\"${CMAKE_BINARY_DIR}/swig/generated/csharp/*.cs\"")
260+
261+
SET(CSHARP_UNITYEDITOR_LIBRARY "/Applications/Unity 2017.1.0f3/Unity.app/Contents/Managed/UnityEditor.dll")
262+
263+
set(CSHARP_REFERENCES /reference:"\"${CSHARP_MSCORLIB_LIBRARY}\"";/reference:"\"${CSHARP_SYSTEM_CORE_LIBRARY}\"";/reference:"\"${CSHARP_SYSTEM_LIBRARY}\"";/reference:"\"${CSHARP_UNITYEDITOR_LIBRARY}\"")
264+
265+
add_custom_target(
266+
class_library ALL
267+
COMMAND "${CS_COMPILE_CMD}"
268+
/noconfig
269+
/nowarn:1701,1702,2008
270+
/langversion:4
271+
/nostdlib+
272+
/warn:4
273+
/optimize+
274+
/out:${CLASS_LIBRARY_NAME}
275+
/target:library
276+
${CSHARP_REFERENCES}
277+
${CSHARP_SOURCES}
278+
${CSHARP_GENERATED_SOURCES}
279+
DEPENDS fbxsdk_csharp globals_replace
280+
COMMENT "Building FbxSharp assembly"
281+
WORKING_DIRECTORY ${CLASS_LIBRARY_DEST}
282+
)
283+
endif()
228284

229-
add_custom_target(
230-
class_library ALL
231-
COMMAND "${CS_COMPILE_CMD}"
232-
/noconfig
233-
/nowarn:1701,1702,2008
234-
/langversion:4
235-
/nostdlib+
236-
/warn:4
237-
/optimize+
238-
/out:${CLASS_LIBRARY_NAME}
239-
/target:library
240-
/reference:"\"${CSHARP_MSCORLIB_LIBRARY}\""
241-
/reference:"\"${CSHARP_SYSTEM_CORE_LIBRARY}\""
242-
/reference:"\"${CSHARP_SYSTEM_LIBRARY}\""
243-
${CMAKE_SOURCE_DIR}/scripts/Properties/AssemblyInfo.cs
244-
${CMAKE_SOURCE_DIR}/src/optimized/*.cs
245-
${CMAKE_BINARY_DIR}/swig/generated/csharp/*.cs
246-
DEPENDS fbxsdk_csharp globals_replace
247-
COMMENT "Building FbxSharp assembly"
248-
WORKING_DIRECTORY ${CLASS_LIBRARY_DEST}
249-
)
250285
add_custom_target(
251286
class_library_dir
252287
COMMAND ${CMAKE_COMMAND} -E make_directory ${CLASS_LIBRARY_DEST}

deps/cmake/FindUnity.cmake

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@ if (NOT DEFINED UNITY_EDITOR_PATH)
1414
set(UNITY_PATH "/Applications/Unity")
1515
set(MONODEVELOP_PATH "${UNITY_PATH}/MonoDevelop.app")
1616
list(APPEND UNITY_EXECUTABLE_PATHS "${UNITY_PATH}/Unity.app/Contents/MacOS/")
17+
1718
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
18-
set(UNITY_PATH "c:/Program Files/Unity")
19+
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
20+
21+
set(UNITY_PATH "c:/Program Files/Unity2017.1.0f3")
1922
set(MONODEVELOP_PATH "${UNITY_PATH}/MonoDevelop")
2023
list(APPEND UNITY_EXECUTABLE_PATHS "${UNITY_PATH}/Editor/")
24+
2125
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
26+
2227
set(UNITY_PATH "/opt/Unity")
2328
set(MONODEVELOP_PATH "${UNITY_PATH}/MonoDevelop")
2429
list(APPEND UNITY_EXECUTABLE_PATHS "${UNITY_PATH}/Editor/")
30+
2531
endif()
2632

2733
find_program(UNITY_EDITOR_PATH Unity PATHS ${UNITY_EXECUTABLE_PATHS})
@@ -32,4 +38,30 @@ else()
3238
message("Using ${UNITY_EDITOR_PATH}")
3339
endif()
3440

41+
if (NOT DEFINED UNITY_EDITOR_DLL_PATH)
42+
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
43+
44+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
45+
get_filename_component(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_PATH}" PATH)
46+
get_filename_component(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_DLL_PATH}" DIRECTORY)
47+
48+
set(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_DLL_PATH}/Managed")
49+
50+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
51+
get_filename_component(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_PATH}" PATH)
52+
set(UNITY_EDITOR_DLL_PATH "${UNITY_EDITOR_DLL_PATH}/Data/Managed")
53+
54+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
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+
endif()
3558

59+
message("Looking for UnityEditor.dll in ${UNITY_EDITOR_DLL_PATH}")
60+
find_library(CSHARP_UNITYEDITOR_LIBRARY UnityEditor.dll PATH ${UNITY_EDITOR_DLL_PATH})
61+
message("Found: ${CSHARP_UNITYEDITOR_LIBRARY}")
62+
63+
# Standard code to report whether we found the package or not.
64+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(UnityEditor DEFAULT_MSG CSHARP_UNITYEDITOR_LIBRARY)
65+
else()
66+
message("Using ${UNITY_EDITOR_DLL_PATH}")
67+
endif()

0 commit comments

Comments
 (0)