Fix setting PAX options for crossgen (#13950)
[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 if(CLR_CMAKE_PLATFORM_UNIX)
79   if(CLR_CMAKE_PLATFORM_LINUX)
80     if(CLR_CMAKE_PLATFORM_UNIX_AMD64 OR CLR_CMAKE_PLATFORM_UNIX_ARM)
81       add_subdirectory(debug/createdump)
82     endif()
83   endif(CLR_CMAKE_PLATFORM_LINUX)
84
85   add_subdirectory(ToolBox/SOS/Strike)
86
87   # Include the dummy c++ include files
88   include_directories("pal/inc/rt/cpp")
89
90   # This prevents inclusion of standard C compiler headers
91   add_compile_options(-nostdinc)
92
93   set (NATIVE_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nativeresources)
94   include_directories(${NATIVE_RESOURCE_DIR})
95   set (RC_TO_CPP ${NATIVE_RESOURCE_DIR}/rctocpp.awk)
96   set (PROCESS_RC ${NATIVE_RESOURCE_DIR}/processrc.awk)
97   set (RESOURCE_STRING_HEADER_DIR ${NATIVE_RESOURCE_DIR})
98
99   # Create a command to create a C++ source file containing an array of
100   # NativeStringResource structs which represent the information from a
101   # given Windows .rc file. The target C++ file path is returned in the
102   # variable specified by the TARGET_FILE parameter.
103   function(build_resources SOURCE TARGET_NAME TARGET_FILE)
104
105     get_compile_definitions(PREPROCESS_DEFINITIONS)
106     get_include_directories(INCLUDE_DIRECTORIES)
107
108     set(PREPROCESSED_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.rc.i)
109     set(RESOURCE_ENTRY_ARRAY_CPP ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.cpp)
110
111     add_custom_command(
112       OUTPUT ${RESOURCE_ENTRY_ARRAY_CPP}
113       # Preprocess the windows .rc file
114       COMMAND ${CMAKE_CXX_COMPILER} -E -P ${PREPROCESS_DEFINITIONS} ${INCLUDE_DIRECTORIES} -o ${PREPROCESSED_SOURCE} -x c ${SOURCE}
115       # Convert the preprocessed .rc file to a C++ file which will be used to make a static lib.
116       COMMAND ${AWK} -v name=${TARGET_NAME} -f ${RC_TO_CPP} -f ${PROCESS_RC} ${PREPROCESSED_SOURCE} >${RESOURCE_ENTRY_ARRAY_CPP}
117             DEPENDS ${SOURCE} ${RC_TO_CPP} ${PROCESS_RC}
118     )
119
120     include_directories(${RESOURCE_STRING_HEADER_DIR})
121     set(${TARGET_FILE} ${RESOURCE_ENTRY_ARRAY_CPP} PARENT_SCOPE)
122
123   endfunction()
124
125   add_subdirectory(nativeresources)
126 endif(CLR_CMAKE_PLATFORM_UNIX)
127
128 add_subdirectory(utilcode)
129 add_subdirectory(gcinfo)
130 add_subdirectory(coreclr)
131 add_subdirectory(jit)
132 add_subdirectory(vm)
133 add_subdirectory(md)
134 add_subdirectory(debug)
135 add_subdirectory(inc)
136 add_subdirectory(strongname)
137 add_subdirectory(binder)
138 add_subdirectory(classlibnative)
139 add_subdirectory(dlls)
140 add_subdirectory(ToolBox)
141 add_subdirectory(tools)
142 add_subdirectory(unwinder)
143 add_subdirectory(ildasm)
144 add_subdirectory(ilasm)
145
146 if(WIN32)
147   add_subdirectory(ipcman)
148 endif(WIN32)
149
150 if(CLR_CMAKE_PLATFORM_UNIX)
151     add_subdirectory(palrt)
152 endif(CLR_CMAKE_PLATFORM_UNIX)