1 # Verify minimum required version
2 cmake_minimum_required(VERSION 2.8.12)
4 if(CMAKE_VERSION VERSION_EQUAL 3.0 OR CMAKE_VERSION VERSION_GREATER 3.0)
5 cmake_policy(SET CMP0042 NEW)
11 # Include cmake functions
12 include(functions.cmake)
14 # Include global configure settings
15 include(configure.cmake)
18 message(STATUS "VS_PLATFORM_TOOLSET is ${CMAKE_VS_PLATFORM_TOOLSET}")
19 message(STATUS "VS_PLATFORM_NAME is ${CMAKE_VS_PLATFORM_NAME}")
22 # Set commonly used directory names
23 set(CLR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
24 set(VM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/vm)
25 set(GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/inc)
26 set(GENERATED_EVENTING_DIR ${CMAKE_CURRENT_BINARY_DIR}/Eventing)
27 set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/version.c")
28 set(PAL_REDEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/dlls/mscordac/palredefines.S)
30 set(CORECLR_SET_RPATH ON)
32 # Enable @rpath support for shared libraries.
34 endif(CORECLR_SET_RPATH)
36 OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
37 OPTION(CLR_CMAKE_WARNINGS_ARE_ERRORS "Warnings are errors" ON)
39 # Ensure other tools are present
41 if(CLR_CMAKE_HOST_ARCH STREQUAL arm)
43 # Confirm that Windows SDK is present
44 if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
45 message(FATAL_ERROR "Windows SDK is required for the Arm32 build.")
47 message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
50 # Explicitly specify the assembler to be used for Arm32 compile
51 file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER)
53 set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
54 message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
56 # Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
57 # use ml[64].exe as the assembler.
59 elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm64)
61 # Confirm that Windows SDK is present
62 if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
63 message(FATAL_ERROR "Windows SDK is required for the ARM64 build.")
65 message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
68 # Explicitly specify the assembler to be used for Arm64 compile
69 file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)
71 set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
72 message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
74 # Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
75 # use ml[64].exe as the assembler.
78 enable_language(ASM_MASM)
81 # Ensure that MC is present
83 if (MC STREQUAL "MC-NOTFOUND")
84 message(FATAL_ERROR "MC not found")
90 # Ensure that awk is present
92 if (AWK STREQUAL "AWK-NOTFOUND")
93 message(FATAL_ERROR "AWK not found")
96 # Try to locate the paxctl tool. Failure to find it is not fatal,
97 # but the generated executables won't work on a system where PAX is set
98 # to prevent applications to create executable memory mappings.
99 find_program(PAXCTL paxctl)
101 if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
103 # Ensure that dsymutil and strip are present
104 find_program(DSYMUTIL dsymutil)
105 if (DSYMUTIL STREQUAL "DSYMUTIL-NOTFOUND")
106 message(FATAL_ERROR "dsymutil not found")
109 find_program(STRIP strip)
110 if (STRIP STREQUAL "STRIP-NOTFOUND")
111 message(FATAL_ERROR "strip not found")
114 else (CMAKE_SYSTEM_NAME STREQUAL Darwin)
116 # Ensure that objcopy is present
117 if (CLR_UNIX_CROSS_BUILD AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
118 if (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
119 find_program(OBJCOPY ${TOOLCHAIN}-objcopy)
120 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
121 find_program(OBJCOPY objcopy)
126 find_program(OBJCOPY objcopy)
129 if (OBJCOPY STREQUAL "OBJCOPY-NOTFOUND")
130 message(FATAL_ERROR "objcopy not found")
133 endif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
136 #----------------------------------------------------
137 # Configure compiler settings for environment
138 #----------------------------------------------------
139 include(configurecompiler.cmake)
141 #----------------------------------------------------
142 # Cross target Component build specific configuration
143 #----------------------------------------------------
144 if(CLR_CROSS_COMPONENTS_BUILD)
145 include(crosscomponents.cmake)
146 endif(CLR_CROSS_COMPONENTS_BUILD)
151 include(pgosupport.cmake)
153 #-----------------------------------------
155 # - project which require platform header not clr's
156 # - do not depend on clr's compile definitions
157 #-----------------------------------------
158 if(CLR_CMAKE_PLATFORM_UNIX AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
159 add_subdirectory(src/corefx)
162 if(CLR_CMAKE_PLATFORM_UNIX)
163 add_subdirectory(src/ToolBox/SOS/lldbplugin)
164 add_subdirectory(src/pal)
165 add_subdirectory(src/coreclr/hosts)
166 add_subdirectory(src/ildasm/unixcoreclrloader)
167 endif(CLR_CMAKE_PLATFORM_UNIX)
169 # Add this subdir. We install the headers for the jit.
170 add_subdirectory(src/pal/prebuilt/inc)
172 add_subdirectory(src/debug/debug-pal)
175 add_subdirectory(src/gc/sample)
178 # Above projects do not build with these compile options
179 # All of the compiler options are specified in file compileoptions.cmake
180 # Do not add any new options here. They should be added in compileoptions.cmake
182 add_compile_options(/FIWarningControl.h) # force include of WarningControl.h
183 add_compile_options(/Zl) # omit default library name in .OBJ
186 #------------------------------
188 #------------------------------
189 if(CLR_CMAKE_BUILD_TESTS)
190 add_subdirectory(tests)
191 endif(CLR_CMAKE_BUILD_TESTS)
193 #--------------------------------
194 # Definition directives
195 # - all clr specific compile definitions should be included in this file
196 # - all clr specific feature variable should also be added in this file
197 #----------------------------------
198 include(clrdefinitions.cmake)
200 #-------------------------------------
201 # Include directory directives
202 #-------------------------------------
203 # Include the basic prebuilt headers - required for getting fileversion resource details.
204 include_directories("src/pal/prebuilt/inc")
205 include_directories("bin/obj")
207 if(FEATURE_STANDALONE_GC)
208 add_definitions(-DFEATURE_STANDALONE_GC)
209 add_subdirectory(src/gc)
210 endif(FEATURE_STANDALONE_GC)
212 if (CLR_CMAKE_PLATFORM_UNIX)
213 include_directories("src/pal/inc")
214 include_directories("src/pal/inc/rt")
215 include_directories("src/pal/src/safecrt")
216 endif (CLR_CMAKE_PLATFORM_UNIX)
218 #------------------------------
219 # Add Product Directory
220 #------------------------------
221 add_subdirectory(src)
223 include(definitionsconsistencycheck.cmake)