diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/cmake/CSharpMacros.cmake | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/cmake/CSharpMacros.cmake')
-rw-r--r-- | linden/indra/cmake/CSharpMacros.cmake | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/linden/indra/cmake/CSharpMacros.cmake b/linden/indra/cmake/CSharpMacros.cmake new file mode 100644 index 0000000..a4dd815 --- /dev/null +++ b/linden/indra/cmake/CSharpMacros.cmake | |||
@@ -0,0 +1,142 @@ | |||
1 | # - This is a support module for easy Mono/C# handling with CMake | ||
2 | # It defines the following macros: | ||
3 | # | ||
4 | # ADD_CS_LIBRARY (<target> <source>) | ||
5 | # ADD_CS_EXECUTABLE (<target> <source>) | ||
6 | # INSTALL_GAC (<target>) | ||
7 | # | ||
8 | # Note that the order of the arguments is important. | ||
9 | # | ||
10 | # You can optionally set the variable CS_FLAGS to tell the macros whether | ||
11 | # to pass additional flags to the compiler. This is particularly useful to | ||
12 | # set assembly references, unsafe code, etc... These flags are always reset | ||
13 | # after the target was added so you don't have to care about that. | ||
14 | # | ||
15 | # copyright (c) 2007 Arno Rehn arno@arnorehn.de | ||
16 | # | ||
17 | # Redistribution and use is allowed according to the terms of the GPL license. | ||
18 | |||
19 | |||
20 | # ----- support macros ----- | ||
21 | MACRO(GET_CS_LIBRARY_TARGET_DIR) | ||
22 | IF (NOT LIBRARY_OUTPUT_PATH) | ||
23 | SET(CS_LIBRARY_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
24 | ELSE (NOT LIBRARY_OUTPUT_PATH) | ||
25 | SET(CS_LIBRARY_TARGET_DIR ${LIBRARY_OUTPUT_PATH}) | ||
26 | ENDIF (NOT LIBRARY_OUTPUT_PATH) | ||
27 | ENDMACRO(GET_CS_LIBRARY_TARGET_DIR) | ||
28 | |||
29 | MACRO(GET_CS_EXECUTABLE_TARGET_DIR) | ||
30 | IF (NOT EXECUTABLE_OUTPUT_PATH) | ||
31 | SET(CS_EXECUTABLE_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
32 | ELSE (NOT EXECUTABLE_OUTPUT_PATH) | ||
33 | SET(CS_EXECUTABLE_TARGET_DIR ${EXECUTABLE_OUTPUT_PATH}) | ||
34 | ENDIF (NOT EXECUTABLE_OUTPUT_PATH) | ||
35 | ENDMACRO(GET_CS_EXECUTABLE_TARGET_DIR) | ||
36 | |||
37 | MACRO(MAKE_PROPER_FILE_LIST) | ||
38 | FOREACH(file ${ARGN}) | ||
39 | # first assume it's a relative path | ||
40 | FILE(GLOB globbed ${CMAKE_CURRENT_SOURCE_DIR}/${file}) | ||
41 | IF(globbed) | ||
42 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${file} native) | ||
43 | ELSE(globbed) | ||
44 | FILE(TO_NATIVE_PATH ${file} native) | ||
45 | ENDIF(globbed) | ||
46 | SET(proper_file_list ${proper_file_list} ${native}) | ||
47 | SET(native "") | ||
48 | ENDFOREACH(file) | ||
49 | ENDMACRO(MAKE_PROPER_FILE_LIST) | ||
50 | # ----- end support macros ----- | ||
51 | |||
52 | MACRO(ADD_CS_LIBRARY target) | ||
53 | GET_CS_LIBRARY_TARGET_DIR() | ||
54 | |||
55 | SET(target_DLL "${CS_LIBRARY_TARGET_DIR}/${target}.dll") | ||
56 | MAKE_PROPER_FILE_LIST(${ARGN}) | ||
57 | FILE(RELATIVE_PATH relative_path ${CMAKE_BINARY_DIR} ${target_DLL}) | ||
58 | |||
59 | SET(target_KEY "${CMAKE_CURRENT_SOURCE_DIR}/${target}.key") | ||
60 | SET(target_CS_FLAGS "${CS_FLAGS}") | ||
61 | IF(${target}_CS_FLAGS) | ||
62 | LIST(APPEND target_CS_FLAGS ${${target}_CS_FLAGS}) | ||
63 | ENDIF(${target}_CS_FLAGS) | ||
64 | IF(EXISTS ${target_KEY}) | ||
65 | LIST(APPEND target_CS_FLAGS -keyfile:${target_KEY}) | ||
66 | ENDIF(EXISTS ${target_KEY}) | ||
67 | |||
68 | FOREACH(ref ${${target}_REFS}) | ||
69 | SET(ref_DLL ${CMAKE_CURRENT_BINARY_DIR}/${ref}.dll) | ||
70 | IF(EXISTS ${ref_DLL}) | ||
71 | LIST(APPEND target_CS_FLAGS -r:${ref_DLL}) | ||
72 | ELSE(EXISTS ${ref_DLL}) | ||
73 | LIST(APPEND target_CS_FLAGS -r:${ref}) | ||
74 | ENDIF(EXISTS ${ref_DLL}) | ||
75 | ENDFOREACH(ref ${${target}_REFS}) | ||
76 | |||
77 | ADD_CUSTOM_COMMAND (OUTPUT ${target_DLL} | ||
78 | COMMAND ${MCS_EXECUTABLE} ${target_CS_FLAGS} -out:${target_DLL} -target:library ${proper_file_list} | ||
79 | MAIN_DEPENDENCY ${proper_file_list} | ||
80 | DEPENDS ${ARGN} | ||
81 | COMMENT "Building ${relative_path}") | ||
82 | ADD_CUSTOM_TARGET (${target} ALL DEPENDS ${target_DLL}) | ||
83 | |||
84 | FOREACH(ref ${${target}_REFS}) | ||
85 | GET_TARGET_PROPERTY(is_target ${ref} TYPE) | ||
86 | IF(is_target) | ||
87 | ADD_DEPENDENCIES(${target} ${ref}) | ||
88 | ENDIF(is_target) | ||
89 | ENDFOREACH(ref ${${target}_REFS}) | ||
90 | |||
91 | SET(relative_path "") | ||
92 | SET(proper_file_list "") | ||
93 | ENDMACRO(ADD_CS_LIBRARY) | ||
94 | |||
95 | MACRO(ADD_CS_EXECUTABLE target) | ||
96 | GET_CS_EXECUTABLE_TARGET_DIR() | ||
97 | |||
98 | # Seems like cmake doesn't like the ".exe" ending for custom commands. | ||
99 | # If we call it ${target}.exe, 'make' will later complain about a missing rule. | ||
100 | # Create a fake target instead. | ||
101 | SET(target_EXE "${CS_EXECUTABLE_TARGET_DIR}/${target}.exe") | ||
102 | SET(target_TOUCH "${CS_EXECUTABLE_TARGET_DIR}/${target}.exe-built") | ||
103 | GET_DIRECTORY_PROPERTY(clean ADDITIONAL_MAKE_CLEAN_FILES) | ||
104 | LIST(APPEND clean ${target}.exe) | ||
105 | SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${clean}") | ||
106 | MAKE_PROPER_FILE_LIST(${ARGN}) | ||
107 | FILE(RELATIVE_PATH relative_path ${CMAKE_BINARY_DIR} ${target_EXE}) | ||
108 | SET(target_CS_FLAGS "${CS_FLAGS}") | ||
109 | |||
110 | FOREACH(ref ${${target}_REFS}) | ||
111 | SET(ref_DLL ${CMAKE_CURRENT_SOURCE_DIR}/${ref}.dll) | ||
112 | IF(EXISTS ${ref_DLL}) | ||
113 | LIST(APPEND target_CS_FLAGS -r:${ref_DLL}) | ||
114 | ELSE(EXISTS ${ref_DLL}) | ||
115 | LIST(APPEND target_CS_FLAGS -r:${ref}) | ||
116 | ENDIF(EXISTS ${ref_DLL}) | ||
117 | ENDFOREACH(ref ${${target}_REFS}) | ||
118 | |||
119 | ADD_CUSTOM_COMMAND (OUTPUT "${target_TOUCH}" | ||
120 | COMMAND ${MCS_EXECUTABLE} ${target_CS_FLAGS} -out:${target_EXE} ${proper_file_list} | ||
121 | COMMAND ${CMAKE_COMMAND} -E touch ${target_TOUCH} | ||
122 | MAIN_DEPENDENCY ${ARGN} | ||
123 | DEPENDS ${ARGN} | ||
124 | COMMENT "Building ${relative_path}") | ||
125 | ADD_CUSTOM_TARGET ("${target}" ALL DEPENDS "${target_TOUCH}") | ||
126 | |||
127 | FOREACH(ref ${${target}_REFS}) | ||
128 | GET_TARGET_PROPERTY(is_target ${ref} TYPE) | ||
129 | IF(is_target) | ||
130 | ADD_DEPENDENCIES(${target} ${ref}) | ||
131 | ENDIF(is_target) | ||
132 | ENDFOREACH(ref ${${target}_REFS}) | ||
133 | |||
134 | SET(relative_path "") | ||
135 | SET(proper_file_list "") | ||
136 | ENDMACRO(ADD_CS_EXECUTABLE) | ||
137 | |||
138 | MACRO(INSTALL_GAC target) | ||
139 | GET_CS_LIBRARY_TARGET_DIR() | ||
140 | |||
141 | INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${GACUTIL_EXECUTABLE} -i ${CS_LIBRARY_TARGET_DIR}/${target}.dll -package 2.0)") | ||
142 | ENDMACRO(INSTALL_GAC target) | ||