-
Notifications
You must be signed in to change notification settings - Fork 1
/
samples.utils.cmake
44 lines (37 loc) · 1.63 KB
/
samples.utils.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Fonctions utilitaires pour compiler les exemples
# Ajoute une cible pour compiler un projet 'C#'
function(arcane_sample_add_csharp_target)
set(options )
set(oneValueArgs TARGET_NAME PROJECT_NAME WORKING_DIRECTORY PUBLISH_DIRECTORY)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT ARGS_TARGET_NAME)
message(FATAL_ERROR "TARGET_NAME not set")
endif()
if (NOT ARGS_PROJECT_NAME)
message(FATAL_ERROR "PROJECT_NAME not set")
endif()
if (NOT ARGS_WORKING_DIRECTORY)
message(FATAL_ERROR "WORKING_DIRECTORY not set")
endif()
if (NOT ARGS_PUBLISH_DIRECTORY)
message(FATAL_ERROR "PUBLISH_DIRECTORY not set")
endif()
set(OUTPUT_DLL ${ARGS_PUBLISH_DIRECTORY}/${ARGS_PROJECT_NAME}.dll)
# Ajoute une commande pour compiler le C# généré par 'swig'
add_custom_command(OUTPUT ${OUTPUT_DLL}
WORKING_DIRECTORY ${ARGS_WORKING_DIRECTORY}
COMMAND ${ARCANE_MSBUILD_EXEC} restore ${ARGS_PROJECT_NAME}.csproj --packages ${ARGS_WORKING_DIRECTORY}
COMMAND ${ARCANE_MSBUILD_EXEC} publish -o ${ARGS_PUBLISH_DIRECTORY} --no-restore ${ARGS_PROJECT_NAME}.csproj
COMMENT "Compiling C# extension for '${ARGS_PROJECT_NAME}'"
DEPENDS ${ARGS_WORKING_DIRECTORY}/${ARGS_PROJECT_NAME}.csproj ${ARGS_DEPENDS}
)
# Ajoute une cible pour la commande de compilation du C# généré
add_custom_target(${ARGS_TARGET_NAME} ALL DEPENDS ${OUTPUT_DLL})
endfunction()
# ----------------------------------------------------------------------------
# Local Variables:
# tab-width: 2
# indent-tabs-mode: nil
# coding: utf-8-with-signature
# End: