@@ -116,3 +116,63 @@ function(rust_package target version script)
116116
117117endfunction ()
118118
119+ function (cargo_package target version )
120+
121+ # Configuration
122+ set (PACKAGE_NAME ${target} )
123+ set (PACKAGE_VERSION ${version} )
124+ set (PACKAGE_OUTPUT "${CMAKE_CURRENT_BINARY_DIR} /build/timestamp" )
125+
126+ set (configuration ${RUST_PROJECT_CONFIG_PATH} /RustProject.cmake.in)
127+ set (language "rust" )
128+ # Define upper and lower versions of the language
129+ string (TOLOWER ${language} language_lower)
130+
131+ # Define project target name
132+ set (custom_target "${language_lower} -${target} " )
133+
134+ # Define target for the configuration
135+ set (PACKAGE_TARGET "${custom_target} " )
136+
137+ # Create project file
138+ configure_file (${configuration} ${custom_target} -config.cmake @ONLY)
139+
140+ # Set custom target
141+ add_custom_target (${custom_target} ALL )
142+
143+ #
144+ # Deployment
145+ #
146+
147+ # Install cmake script config
148+ #install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${custom_target}/${custom_target}-config.cmake"
149+ # DESTINATION ${INSTALL_CMAKE}/${custom_target}
150+ # COMPONENT runtime
151+ #)
152+
153+ # CMake config
154+ #install(EXPORT ${custom_target}-export
155+ # NAMESPACE ${META_PROJECT_NAME}::
156+ # DESTINATION ${INSTALL_CMAKE}/${custom_target}
157+ # COMPONENT dev
158+ #)
159+
160+ # Set project properties
161+ set_target_properties (${custom_target}
162+ PROPERTIES
163+ ${DEFAULT_PROJECT_OPTIONS}
164+ FOLDER "${IDE_FOLDER} /${language} "
165+ )
166+
167+ # Compile project
168+ add_custom_command (TARGET ${custom_target} PRE_BUILD
169+ # fix the version of rustc
170+ COMMAND ${Rust_RUSTUP_EXECUTABLE} default nightly-2021-12-04
171+ COMMAND ${Rust_CARGO_EXECUTABLE} build
172+ --manifest-path ${CMAKE_CURRENT_SOURCE_DIR} /Cargo.toml
173+ --target -dir ${LOADER_SCRIPT_PATH}
174+ )
175+
176+ # Include generated project file
177+ include (${CMAKE_CURRENT_BINARY_DIR} /${custom_target} -config.cmake)
178+ endfunction ()
0 commit comments