Make createdump build and work on ARM (#12798)
[platform/upstream/coreclr.git] / src / CMakeLists.txt
1 include_directories("inc")
2 include_directories("strongname/inc")
3 include_directories("inc/winrt")
4 include_directories("debug/inc")
5 include_directories("debug/inc/${ARCH_SOURCES_DIR}")
6 include_directories("debug/inc/dump")
7 include_directories("md/inc")
8 include_directories("classlibnative/bcltype")
9 include_directories("classlibnative/cryptography")
10 include_directories("classlibnative/inc")
11 include_directories("${GENERATED_INCLUDE_DIR}")
12
13 # The Following Logic is used to wire up Build dependencies for Generated files in Event Logging 
14 # ClrEtwAll.man                  - Event Schema
15 # ClrEtwAllMeta.lst              - MetaData list [provided to ensure Windows Desktop is not broken]
16 # genXplatEventing.py            - has the core logic for parsing Event Schema
17 # genWinEtw.py                   - Uses genXplatEventing to generate Windows Specific ETW Files
18 # clretwallmain.h and etmdummy.h - Provides the Event Logging Functionality to the VM
19 # clrxplatevents.h               - Used by clretwallmain.h on Non Windows platform
20 # ClrEtwAll.h                    - Used by clretwallmain.h on  Windows 
21 # ClrEtwAll.rc                   - Used by src/dlls/clretwrc/clretrw.rc on Windows
22
23 set (ScriptGeneratedEventFiles
24       ${GENERATED_INCLUDE_DIR}/clretwallmain.h
25       ${GENERATED_INCLUDE_DIR}/etmdummy.h
26 )
27 set (GeneratedEventFiles)
28
29 if(WIN32)
30     set (GenEventFilesScript "${CLR_DIR}/src/scripts/genWinEtw.py")
31     set (GenEventArgs --eventheader "${GENERATED_INCLUDE_DIR}/ClrEtwAll.h" --macroheader "${GENERATED_INCLUDE_DIR}/clretwallmain.h")
32
33     list (APPEND ScriptGeneratedEventFiles
34           ${GENERATED_INCLUDE_DIR}/ClrEtwAll.h
35     )
36
37     list (APPEND GeneratedEventFiles
38          ${GENERATED_INCLUDE_DIR}/ClrEtwAll.rc
39     )
40
41     add_custom_command(
42       COMMENT "Generating ETW resource Files"
43       COMMAND ${MC} -h ${GENERATED_INCLUDE_DIR} -r ${GENERATED_INCLUDE_DIR} -b -co -um -p FireEtw "${VM_DIR}/ClrEtwAll.man"
44       OUTPUT ${GENERATED_INCLUDE_DIR}/ClrEtwAll.h
45       DEPENDS "${VM_DIR}/ClrEtwAll.man"
46     )
47 else()
48     set (GenEventFilesScript "${CLR_DIR}/src/scripts/genXplatEventing.py")
49     set (GenEventArgs   --inc  "${GENERATED_INCLUDE_DIR}")
50
51     list (APPEND ScriptGeneratedEventFiles
52           ${GENERATED_INCLUDE_DIR}/clrxplatevents.h
53     )
54 endif(WIN32)
55
56 if(CLR_CMAKE_WARNINGS_ARE_ERRORS)
57     set(PYTHON_WARNING_FLAGS -Wall -Werror)
58 else()
59     set(PYTHON_WARNING_FLAGS -Wall)
60 endif(CLR_CMAKE_WARNINGS_ARE_ERRORS)
61
62 add_custom_command(
63   COMMENT "Generating Eventing Files"
64   COMMAND ${PYTHON} -B ${PYTHON_WARNING_FLAGS} ${GenEventFilesScript} ${GenEventArgs} --man "${VM_DIR}/ClrEtwAll.man" --exc "${VM_DIR}/ClrEtwAllMeta.lst" --dummy "${GENERATED_INCLUDE_DIR}/etmdummy.h"
65   OUTPUT ${ScriptGeneratedEventFiles}
66   DEPENDS ${GenEventFilesScript} "${VM_DIR}/ClrEtwAll.man" "${VM_DIR}/ClrEtwAllMeta.lst" "${CLR_DIR}/src/scripts/genXplatEventing.py"
67 )
68
69 list (APPEND GeneratedEventFiles
70       ${ScriptGeneratedEventFiles}
71 )
72
73 add_custom_target(
74   GeneratedEventingFiles
75   DEPENDS ${GeneratedEventFiles}
76 )
77
78 function(add_library_clr)
79     if(NOT WIN32)
80       add_library(${ARGV} ${VERSION_FILE_PATH})
81     else()
82       add_library(${ARGV})
83     endif(NOT WIN32)
84     add_dependencies(${ARGV0} GeneratedEventingFiles)
85     list(FIND CLR_CROSS_COMPONENTS_LIST ${ARGV0} INDEX)  
86     if (DEFINED CLR_CROSS_COMPONENTS_LIST AND ${INDEX} EQUAL -1)  
87      set_target_properties(${ARGV0} PROPERTIES EXCLUDE_FROM_ALL 1)  
88     endif()  
89 endfunction()
90
91 function(add_executable_clr)
92     if(NOT WIN32)
93       add_executable(${ARGV} ${VERSION_FILE_PATH})
94     else()
95       add_executable(${ARGV})
96     endif(NOT WIN32)
97     add_dependencies(${ARGV0} GeneratedEventingFiles)
98     list(FIND CLR_CROSS_COMPONENTS_LIST ${ARGV0} INDEX)  
99     if (DEFINED CLR_CROSS_COMPONENTS_LIST AND ${INDEX} EQUAL -1)  
100      set_target_properties(${ARGV0} PROPERTIES EXCLUDE_FROM_ALL 1)  
101     endif()  
102 endfunction()
103
104 if(CLR_CMAKE_PLATFORM_UNIX)
105   if(CLR_CMAKE_PLATFORM_LINUX)
106     if(CLR_CMAKE_PLATFORM_UNIX_AMD64 OR CLR_CMAKE_PLATFORM_UNIX_ARM)
107       add_subdirectory(debug/createdump)
108     endif()
109   endif(CLR_CMAKE_PLATFORM_LINUX)
110
111   add_subdirectory(ToolBox/SOS/Strike)
112
113   # Include the dummy c++ include files
114   include_directories("pal/inc/rt/cpp")
115
116   # This prevents inclusion of standard C compiler headers
117   add_compile_options(-nostdinc)
118
119   set (NATIVE_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nativeresources)
120   include_directories(${NATIVE_RESOURCE_DIR})
121   set (RC_TO_CPP ${NATIVE_RESOURCE_DIR}/rctocpp.awk)
122   set (PROCESS_RC ${NATIVE_RESOURCE_DIR}/processrc.awk)
123   set (RESOURCE_STRING_HEADER_DIR ${NATIVE_RESOURCE_DIR})
124
125   # Create a command to create a C++ source file containing an array of
126   # NativeStringResource structs which represent the information from a
127   # given Windows .rc file. The target C++ file path is returned in the
128   # variable specified by the TARGET_FILE parameter.
129   function(build_resources SOURCE TARGET_NAME TARGET_FILE)
130
131     get_compile_definitions(PREPROCESS_DEFINITIONS)
132     get_include_directories(INCLUDE_DIRECTORIES)
133
134     set(PREPROCESSED_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.rc.i)
135     set(RESOURCE_ENTRY_ARRAY_CPP ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.cpp)
136
137     add_custom_command(
138       OUTPUT ${RESOURCE_ENTRY_ARRAY_CPP}
139       # Preprocess the windows .rc file
140       COMMAND ${CMAKE_CXX_COMPILER} -E -P ${PREPROCESS_DEFINITIONS} ${INCLUDE_DIRECTORIES} -o ${PREPROCESSED_SOURCE} -x c ${SOURCE}
141       # Convert the preprocessed .rc file to a C++ file which will be used to make a static lib.
142       COMMAND ${AWK} -v name=${TARGET_NAME} -f ${RC_TO_CPP} -f ${PROCESS_RC} ${PREPROCESSED_SOURCE} >${RESOURCE_ENTRY_ARRAY_CPP}
143             DEPENDS ${SOURCE} ${RC_TO_CPP} ${PROCESS_RC}
144     )
145
146     include_directories(${RESOURCE_STRING_HEADER_DIR})
147     set(${TARGET_FILE} ${RESOURCE_ENTRY_ARRAY_CPP} PARENT_SCOPE)
148
149   endfunction()
150
151   add_subdirectory(nativeresources)
152 endif(CLR_CMAKE_PLATFORM_UNIX)
153
154 add_subdirectory(utilcode)
155 add_subdirectory(gcinfo)
156 add_subdirectory(coreclr)
157 add_subdirectory(jit)
158 if(FEATURE_STANDALONE_GC)
159   add_subdirectory(gc)
160 endif(FEATURE_STANDALONE_GC)
161 add_subdirectory(vm)
162 add_subdirectory(md)
163 add_subdirectory(debug)
164 add_subdirectory(inc)
165 add_subdirectory(strongname)
166 add_subdirectory(binder)
167 add_subdirectory(classlibnative)
168 add_subdirectory(dlls)
169 add_subdirectory(ToolBox)
170 add_subdirectory(tools)
171 add_subdirectory(unwinder)
172 add_subdirectory(ildasm)
173 add_subdirectory(ilasm)
174
175 if(WIN32)
176   add_subdirectory(ipcman)
177 endif(WIN32)
178
179 if(CLR_CMAKE_PLATFORM_UNIX)
180     add_subdirectory(palrt)
181 endif(CLR_CMAKE_PLATFORM_UNIX)