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.cpp")
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 that python is present
40 find_program(PYTHON NAMES python2.7 python2 python)
41 if (PYTHON STREQUAL "PYTHON-NOTFOUND")
42 message(FATAL_ERROR "PYTHON not found: Please install Python 2.7.9 or later from https://www.python.org/downloads/")
45 # Ensure other tools are present
47 if(CLR_CMAKE_HOST_ARCH STREQUAL arm)
49 # Confirm that Windows SDK is present
50 if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
51 message(FATAL_ERROR "Windows SDK is required for the Arm32 build.")
53 message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
56 # Explicitly specify the assembler to be used for Arm32 compile
57 if($ENV{__VSVersion} STREQUAL "vs2015")
58 file(TO_CMAKE_PATH "$ENV{VCINSTALLDIR}\\bin\\x86_arm\\armasm.exe" CMAKE_ASM_COMPILER)
60 file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER)
63 set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
64 message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
66 # Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
67 # use ml[64].exe as the assembler.
69 elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm64)
71 # Confirm that Windows SDK is present
72 if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
73 message(FATAL_ERROR "Windows SDK is required for the ARM64 build.")
75 message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
78 # Explicitly specify the assembler to be used for Arm64 compile
79 file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)
81 set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
82 message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
84 # Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
85 # use ml[64].exe as the assembler.
88 enable_language(ASM_MASM)
91 # Ensure that MC is present
93 if (MC STREQUAL "MC-NOTFOUND")
94 message(FATAL_ERROR "MC not found")
100 # Ensure that awk is present
101 find_program(AWK awk)
102 if (AWK STREQUAL "AWK-NOTFOUND")
103 message(FATAL_ERROR "AWK not found")
106 # Try to locate the paxctl tool. Failure to find it is not fatal,
107 # but the generated executables won't work on a system where PAX is set
108 # to prevent applications to create executable memory mappings.
109 find_program(PAXCTL paxctl)
111 if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
113 # Ensure that dsymutil and strip are present
114 find_program(DSYMUTIL dsymutil)
115 if (DSYMUTIL STREQUAL "DSYMUTIL-NOTFOUND")
116 message(FATAL_ERROR "dsymutil not found")
119 find_program(STRIP strip)
120 if (STRIP STREQUAL "STRIP-NOTFOUND")
121 message(FATAL_ERROR "strip not found")
124 else (CMAKE_SYSTEM_NAME STREQUAL Darwin)
126 # Ensure that objcopy is present
127 if (CLR_UNIX_CROSS_BUILD AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
128 if (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
129 find_program(OBJCOPY ${TOOLCHAIN}-objcopy)
130 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
131 find_program(OBJCOPY objcopy)
136 find_program(OBJCOPY objcopy)
139 if (OBJCOPY STREQUAL "OBJCOPY-NOTFOUND")
140 message(FATAL_ERROR "objcopy not found")
143 endif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
146 #----------------------------------------------------
147 # Configure compiler settings for environment
148 #----------------------------------------------------
149 include(configurecompiler.cmake)
151 #----------------------------------------------------
152 # Cross target Component build specific configuration
153 #----------------------------------------------------
154 if(CLR_CROSS_COMPONENTS_BUILD)
155 include(crosscomponents.cmake)
156 endif(CLR_CROSS_COMPONENTS_BUILD)
161 include(pgosupport.cmake)
163 #-----------------------------------------
165 # - project which require platform header not clr's
166 # - do not depend on clr's compile definitions
167 #-----------------------------------------
168 if(CLR_CMAKE_PLATFORM_UNIX AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
169 add_subdirectory(src/corefx)
172 if(CLR_CMAKE_PLATFORM_UNIX)
173 add_subdirectory(src/ToolBox/SOS/lldbplugin)
174 add_subdirectory(src/pal)
175 add_subdirectory(src/coreclr/hosts)
176 add_subdirectory(src/ildasm/unixcoreclrloader)
177 endif(CLR_CMAKE_PLATFORM_UNIX)
179 # Add this subdir. We install the headers for the jit.
180 add_subdirectory(src/pal/prebuilt/inc)
182 add_subdirectory(src/debug/debug-pal)
185 add_subdirectory(src/gc/sample)
188 # Above projects do not build with these compile options
189 # All of the compiler options are specified in file compileoptions.cmake
190 # Do not add any new options here. They should be added in compileoptions.cmake
192 add_compile_options(/FIWarningControl.h) # force include of WarningControl.h
193 add_compile_options(/Zl) # omit default library name in .OBJ
196 #------------------------------
198 #------------------------------
199 if(CLR_CMAKE_BUILD_TESTS)
200 add_subdirectory(tests)
201 endif(CLR_CMAKE_BUILD_TESTS)
203 #--------------------------------
204 # Definition directives
205 # - all clr specific compile definitions should be included in this file
206 # - all clr specific feature variable should also be added in this file
207 #----------------------------------
208 include(clrdefinitions.cmake)
210 #-------------------------------------
211 # Include directory directives
212 #-------------------------------------
213 # Include the basic prebuilt headers - required for getting fileversion resource details.
214 include_directories("src/pal/prebuilt/inc")
215 include_directories("bin/obj")
217 if(FEATURE_STANDALONE_GC)
218 add_definitions(-DFEATURE_STANDALONE_GC)
219 add_subdirectory(src/gc)
220 endif(FEATURE_STANDALONE_GC)
222 if (CLR_CMAKE_PLATFORM_UNIX)
223 include_directories("src/pal/inc")
224 include_directories("src/pal/inc/rt")
225 include_directories("src/pal/src/safecrt")
226 endif (CLR_CMAKE_PLATFORM_UNIX)
228 # Microsoft.Dotnet.BuildTools.Coreclr version
229 set(BuildToolsVersion "1.0.4-prerelease")
230 set(BuildToolsDir "${CLR_CMAKE_PACKAGES_DIR}/Microsoft.DotNet.BuildTools.CoreCLR/${BuildToolsVersion}")
232 #------------------------------
233 # Add Product Directory
234 #------------------------------
235 add_subdirectory(src)
237 include(definitionsconsistencycheck.cmake)