1 # Require at least version 2.8.12 of CMake
2 cmake_minimum_required(VERSION 2.8.12)
4 if (CMAKE_CONFIGURATION_TYPES) # multi-configuration generator?
5 set(CMAKE_CONFIGURATION_TYPES "Debug;Checked;Release;RelWithDebInfo" CACHE STRING "" FORCE)
6 endif (CMAKE_CONFIGURATION_TYPES)
7 set(CMAKE_C_FLAGS_CHECKED "")
8 set(CMAKE_CXX_FLAGS_CHECKED "")
9 set(CMAKE_EXE_LINKER_FLAGS_CHECKED "")
10 set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "")
12 set(CLR_CMAKE_TARGET_ARCH ${CLR_CMAKE_HOST_ARCH})
14 set(INC_PLATFORM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Common/Platform)
16 add_definitions(-DWINDOWS=1)
18 if (DEFINED ENV{__ToolsetDir})
19 # Hack for private Tool Set
20 # CMAKE_CXX_COMPILER will default to the compiler installed with
21 # Visual studio. Overwrite it to the compiler on the path.
23 find_program(PATH_CXX_COMPILER cl)
24 set(CMAKE_CXX_COMPILER ${PATH_CXX_COMPILER})
26 message("Overwriting the CMAKE_CXX_COMPILER.")
27 message("CMAKE_CXX_COMPILER found:${CMAKE_CXX_COMPILER}")
29 # Temporary until cmake has VS generators for hacky toolsets [arm64]
30 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /machine:${CLR_CMAKE_TARGET_ARCH}")
31 set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /machine:${CLR_CMAKE_TARGET_ARCH}")
32 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /machine:${CLR_CMAKE_TARGET_ARCH}")
39 # 4100 - unreferenced formal parameter
40 # 4514 - unreferenced inline function has been removed
41 # 4625 - copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted
42 # 4626 - assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted
43 # 4668 - 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives'
44 # 4710 - function not inlined
45 # 4711 - 'function' selected for inline expansion
46 # 4774 - format string expected in argument number is not a string literal
47 # 4820 - bytes padding added after construct 'member_name'
48 # 5025 - move assignment operator was implicitly defined as deleted
49 # 5026 - move constructor was implicitly defined as deleted
50 # 5027 - move assignment operator was implicitly defined as deleted
51 # 5039 - pointer or reference to potentially throwing function passed to extern C function under -EHc. Undefined behavior may occur if this function throws an exception.
52 add_compile_options(-wd4100 -wd4514 -wd4625 -wd4626 -wd4668 -wd4710 -wd4711 -wd4774 -wd4820 -wd5025 -wd5026 -wd5027 -wd5039)
53 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
56 if(CLR_CMAKE_PLATFORM_UNIX)
57 add_compile_options(-fPIC)
58 endif(CLR_CMAKE_PLATFORM_UNIX)
60 MACRO(SUBDIRLIST result curdir)
61 FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
63 FOREACH(child ${children})
64 IF(IS_DIRECTORY ${curdir}/${child})
65 LIST(APPEND dirlist ${child})
68 SET(${result} ${dirlist})
71 MACRO(ADDSUBDIR_REC curdir)
72 SUBDIRLIST(SUB_DIRS ${curdir})
73 FOREACH(subdir ${SUB_DIRS})
74 if(EXISTS "${curdir}/${subdir}/CMakeLists.txt")
75 ADD_SUBDIRECTORY(${curdir}/${subdir})
77 ADDSUBDIR_REC(${curdir}/${subdir})
78 endif(EXISTS "${curdir}/${subdir}/CMakeLists.txt")
82 ADDSUBDIR_REC(${CMAKE_CURRENT_SOURCE_DIR})