!XT (Git) Synchronizing Git repositories to Perforce
[CRYENGINE.git] / Code / CryManaged / CryMonoBridge / CMakeLists.txt
blobc288e1199bb1dc756efb7605c05dc5faee006e77
1 #START-FILE-LIST
2 # File List auto generated by waf2cmake.py, do not modify manually.
4 start_sources()
5 # -- crymonobridge.waf_files --
6 sources_platform(ALL)
7 add_sources("CryMonoBridge_main_uber_1.cpp"
8         SOURCE_GROUP "Root"
9                 "MonoRuntime.h"
10                 "MonoRuntime.cpp"
11                 "ManagedPlugin.h"
12                 "ManagedPlugin.cpp"
13                 "resource.h"
14                 "StdAfx.h"
17 add_sources("CryMonoBridge_main_uber_2.cpp"
18         SOURCE_GROUP "Wrappers"
19                 "Wrappers/MonoDomain.h"
20                 "Wrappers/MonoDomain.cpp"
21                 "Wrappers/RootMonoDomain.h"
22                 "Wrappers/RootMonoDomain.cpp"
23                 "Wrappers/AppDomain.h"
24                 "Wrappers/AppDomain.cpp"
25                 "Wrappers/MonoLibrary.h"
26                 "Wrappers/MonoLibrary.cpp"
27                 "Wrappers/CompiledMonoLibrary.h"
28                 "Wrappers/CompiledMonoLibrary.cpp"
29                 "Wrappers/MonoClass.h"
30                 "Wrappers/MonoClass.cpp"
31                 "Wrappers/MonoObject.h"
32                 "Wrappers/MonoObject.cpp"
33                 "Wrappers/MonoException.h"
34                 "Wrappers/MonoException.cpp"
35                 "Wrappers/MonoMethod.h"
36                 "Wrappers/MonoMethod.cpp"
37                 "Wrappers/MonoString.h"
38                 "Wrappers/MonoString.cpp"
39                 "Wrappers/MonoProperty.h"
40                 "Wrappers/MonoProperty.cpp"
43 add_sources("CryMonoBridge_main_uber_3.cpp"
44         SOURCE_GROUP "NativeComponents"
45                 "NativeComponents/EntityComponentFactory.h"
46                 "NativeComponents/EntityComponentFactory.cpp"
47                 "NativeComponents/ManagedEntityComponent.h"
48                 "NativeComponents/ManagedEntityComponent.cpp"
51 add_sources("CryMonoBridge_main_uber_4.cpp"
52         SOURCE_GROUP "NativeToManagedInterfaces"
53                 "NativeToManagedInterfaces/IMonoNativeToManagedInterface.h"
54                 "NativeToManagedInterfaces/Entity.h"
55                 "NativeToManagedInterfaces/Entity.cpp"
56                 "NativeToManagedInterfaces/Console.h"
57                 "NativeToManagedInterfaces/Console.cpp"
58                 "NativeToManagedInterfaces/Audio.h"
59                 "NativeToManagedInterfaces/Audio.cpp"
62 if (OPTION_CRYMONO_SWIG)
63         add_sources("CryMonoBridge_SWIG.cpp"
64                 SOURCE_GROUP "SWIG"
65                         "SWIG/CryEngine.swig"
66                         "SWIG/CryAction.i"
67                         "SWIG/Cry3DEngine.i"
68                         "SWIG/CryAISystem.i"
69                         "SWIG/CryAnimation.i"
70                         "SWIG/CryAudio.i"
71                         "SWIG/CryCommon.i"
72                         "SWIG/CryDynamicResponseSystem.i"
73                         "SWIG/CryEntitySystem.i"
74                         "SWIG/CryFont.i"
75                         "SWIG/CryInput.i"
76                         "SWIG/CryMonoBridge.i"
77                         "SWIG/CryLiveCreate.i"
78                         "SWIG/CryLobby.i"
79                         "SWIG/CryMovie.i"
80                         "SWIG/CryNetwork.i"
81                         "SWIG/CryPhysics.i"
82                         "SWIG/CryRender.i"
83                         "SWIG/CryScriptSystem.i"
84                         "SWIG/CrySystem.i"
85                         "SWIG/ForwardDeclarations.i"
86         )
87 endif()
89 add_sources("NoUberFile"
90         SOURCE_GROUP "Root"
91                 "StdAfx.cpp"
94 end_sources()
95 #END-FILE-LIST
97 CryEngineModule(CryMonoBridge FORCE_SHARED_WIN PCH "StdAfx.cpp" SOLUTION_FOLDER "CryMono")
98 target_compile_options(${THIS_PROJECT} PRIVATE /EHsc /bigobj)
99 target_include_directories(${THIS_PROJECT} PRIVATE "${CRYENGINE_DIR}/Code/CryEngine/CryAction" )
101 # c# assembly generation should be uniform across all projects for 32 bit and 64 bit.
102 # Currently there are 4 other assemblies being generated
103 # 1. CryEngine.Common
104 # 2. CryEngine.Core
105 # 3. CryEngine.Core.UI
106 # 4. CryEngine.Core.Tests
108 if (OPTION_CRYMONO_SWIG)
109         # Create the common mono assembly generation environment variables
110         create_mono_compiler_settings()
112         # Build SWIG
113         set(CMAKE_MODULE_LINKER_FLAGS_PROFILE ${CMAKE_SHARED_LINKER_FLAGS_PROFILE})
114         set(swig_inputs)
115         set(swig_globals)
116         foreach(sourcefile ${SOURCES})
117                 if ("${sourcefile}" MATCHES ".*\\.\\i$")
118                         set(swig_inputs ${swig_inputs} "${sourcefile}")
119                 endif()
120                 if ("${sourcefile}" MATCHES ".*\\.\\swig$")
121                         set(swig_globals ${swig_globals} "${sourcefile}")
122                 endif()
123         endforeach()
125         set(SWIG_EXECUTABLE "${SDK_DIR}/swig/swig")
127         if (NOT PRODUCT_NAME)
128                 set(PRODUCT_NAME ${THIS_PROJECT})
129         endif()
130         file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${MONO_SWIG_OUTPUT_ASSEMBLY_NAME}_meta.cs"
131                 "using System.Reflection;\n"
132                 "using System.Runtime.CompilerServices;\n"
133                 "[assembly: InternalsVisibleTo(\"CryEngine.Core\")]\n"
134                 "[assembly: AssemblyProduct(\"${PRODUCT_NAME}\")]\n"
135                 "[assembly: AssemblyTitle(\"${PRODUCT_NAME}\")]\n"
136                 "[assembly: AssemblyDescription(\"${PRODUCT_NAME}\")]\n"
137                 "[assembly: AssemblyVersion(\"${METADATA_VERSION}\")]\n"
138                 "[assembly: AssemblyCompany(\"${METADATA_COMPANY}\")]\n"
139                 "[assembly: AssemblyCopyright(\"${METADATA_COPYRIGHT}\")]\n"
140                 )
142         set(mono_inputs "${CMAKE_CURRENT_BINARY_DIR}/${MONO_SWIG_OUTPUT_ASSEMBLY_NAME}_meta.cs")
144         foreach(f ${swig_inputs})
145                 string(LENGTH "${f}" flen)
146                 math(EXPR flen ${flen}-2)
147                 string(SUBSTRING "${f}" 0 ${flen} basename)
148                 file(RELATIVE_PATH bindir "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
149                 set(basename "${basename}")
150                 set(f_cpp "${basename}.cpp")
151                 set(f_cs "${basename}.cs")
152                 set(f_h "${basename}.h")
153                 if(WINDOWS)
154                         set(defs -D_WIN32 -D_WIN64)
155                 else()
156                         message(ERROR "Mono not supported on this platform")
157                 endif()
159                 get_target_property(target_defs ${THIS_PROJECT} COMPILE_DEFINITIONS)
160                 foreach(d ${target_defs})
161                         set(defs ${defs} -D${d})
162                 endforeach()
163                 set(defs ${defs} -D_MT -D_DLL -D_USRDLL)
165                 get_filename_component(f_cs_dir "${f_cs}" DIRECTORY)
166                 get_filename_component(f_cs_name "${f_cs}" NAME)
168                 # Detect dependencies
169                 execute_process(
170                         COMMAND "${SWIG_EXECUTABLE}" -MM ${defs} -csharp "${f}"
171                         OUTPUT_VARIABLE swig_deps
172                         WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
173                 )
174                 string(REGEX MATCHALL "\n  [^ ][^ ][^ :]+" temp ${swig_deps})
175                 set(swig_deps)
176                 foreach(t ${temp})
177                         string(STRIP "${t}" t)
178                         set(swig_deps ${swig_deps} "${t}")
179                 endforeach()
181                 set(defs ${defs} -D_$<UPPER_CASE:$<CONFIG>> -D$<UPPER_CASE:$<CONFIG>>)
183                 set(mono_inputs ${mono_inputs} "${f_cs}")
184                 add_custom_command(
185                         OUTPUT "${f_cpp}" "${f_h}" "${f_cs}"
186                         COMMAND "${SWIG_EXECUTABLE}" -c++ ${defs} -DSWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR ${secondary_defs} -csharp -o "${bindir}/${f_cpp}" -outdir "${bindir}/${f_cs_dir}" -outfile "${f_cs_name}" -namespace ${MONO_SWIG_OUTPUT_ASSEMBLY_NAME} -pch-file "\\\"StdAfx.h\\\"" -fno-include-guards -dllimport ${THIS_PROJECT} "${f}"
187                         MAIN_DEPENDENCY "${f}"
188                         WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
189                         DEPENDS ${swig_deps}
190                 )
191                 set_property(DIRECTORY "${CRYENGINE_DIR}" APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${swig_deps} "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
192                 set(secondary_defs -DSWIG_CXX_EXCLUDE_SWIG_INTERFACE_FUNCTIONS -DSWIG_CSHARP_EXCLUDE_STRING_HELPER -DSWIG_CSHARP_EXCLUDE_EXCEPTION_HELPER)
193                 target_sources(${THIS_PROJECT} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${f_cpp}" "${CMAKE_CURRENT_BINARY_DIR}/${f_h}")
194                 EXCLUDE_FILE_FROM_MSVC_PRECOMPILED_HEADER("${CMAKE_CURRENT_BINARY_DIR}/${f_cpp}")
195                 source_group("Generated" FILES "${CMAKE_CURRENT_BINARY_DIR}/${f_cpp}" "${CMAKE_CURRENT_BINARY_DIR}/${f_h}")
196                 set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${f_h}" PROPERTIES HEADER_FILE_ONLY true GENERATED true)
197         endforeach()
199         add_custom_command(
200                 TARGET ${THIS_PROJECT} PRE_LINK
201                 COMMAND "${CSC_PATH}" /target:library /langversion:${MONO_LANGUAGE_VERSION} /platform:${MONO_CPU_PLATFORM} /optimize /debug:portable ${mono_inputs} /out:"${OUTPUT_DIRECTORY}/${MONO_SWIG_OUTPUT_ASSEMBLY_NAME}.dll"
202                 DEPENDS ${mono_inputs}
203                 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
204         )
205 endif()
207 if(WINDOWS)
208         target_include_directories(${THIS_PROJECT} PRIVATE "${SDK_DIR}/Mono/include/mono-2.0")
209         set_libpath_flag()
210         set_property(TARGET ${THIS_PROJECT} APPEND_STRING PROPERTY LINK_FLAGS " ${LIBPATH_FLAG}\"${SDK_DIR}/Mono/lib/x64\"")
211         target_link_libraries(${THIS_PROJECT} PRIVATE Shell32 libmono-static-sgen Mswsock Psapi Winmm version Shlwapi)
212 endif()