Merge pull request #64 from i-kulaychuk/disable-ni-x86
[sdk/tools/netcoredbg.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.12.2)
2 project(netcoredbg)
3
4 set(CLR_DIR "${CMAKE_SOURCE_DIR}/../coreclr" CACHE FILEPATH "Path to coreclr directory")
5 set(CLR_BIN_DIR "" CACHE FILEPATH "Path to coreclr bin directory")
6 set(BUILD_MANAGED ON CACHE BOOL "Build managed part")
7 set(DBGSHIM_DIR "" CACHE FILEPATH "Path to dbgshim library directory")
8
9 if (WIN32)
10     set(CMAKE_CXX_STANDARD 11)
11 else()
12     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-null-conversion")
13 endif()
14
15 function(clr_unknown_arch)
16     message(FATAL_ERROR "Only AMD64, ARM64, ARM, ARMEL, I386 and WASM are supported")
17 endfunction()
18
19 if (WIN32)
20     # For windows it is expected that CLR_CMAKE_HOST_ARCH parameter is passed
21     # to CMAKE to determine build arch.
22     # If it is not passed, detect arch here.
23     if ("${CLR_CMAKE_HOST_ARCH}" STREQUAL "")
24         if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
25             set(CLR_CMAKE_HOST_ARCH x86)
26         else()
27             set(CLR_CMAKE_HOST_ARCH x64)
28         endif()
29     endif()
30 endif()
31
32 # Follow order as in root CoreCLR CMakeLists.txt
33 include(detectplatform.cmake) # from root
34 include(platformdefinitions.cmake) # from root
35 include(compileoptions.cmake) # disabled setting arm compiler flags in Tizen build
36 include(clrdefinitions.cmake)
37
38 if (NOT IS_DIRECTORY "${CLR_DIR}")
39     message(FATAL_ERROR "Unable to find CoreCLR directory")
40 endif()
41
42 set(CLR_CONFIGURATION_TYPES "Debug;Checked;Release;RelWithDebInfo" CACHE STRING "")
43
44 if ("${CLR_BIN_DIR}" STREQUAL "")
45     if (WIN32)
46         set(TARGET_OS_NAME "Windows_NT")
47     elseif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
48         set(TARGET_OS_NAME "OSX")
49     elseif (CMAKE_SYSTEM_NAME STREQUAL Linux)
50         set(TARGET_OS_NAME "Linux")
51     endif()
52
53     # TODO: Search for CMAKE_BUILD_TYPE configuration first
54     # TODO: CLR_CMAKE_TARGET_ARCH may be armel
55     foreach(CONFIG IN LISTS CLR_CONFIGURATION_TYPES)
56         set(CLR_BIN_DIR ${CLR_DIR}/bin/Product/${TARGET_OS_NAME}.${CLR_CMAKE_TARGET_ARCH}.${CONFIG})
57         if (IS_DIRECTORY "${CLR_BIN_DIR}")
58             break()
59         endif()
60     endforeach()
61
62     if (IS_DIRECTORY "${CLR_BIN_DIR}")
63         message(STATUS "CoreCLR bin directory: " ${CLR_BIN_DIR})
64     else()
65         message(FATAL_ERROR "Unable to find CoreCLR bin directory")
66     endif()
67 endif()
68
69 add_subdirectory(src/debug/netcoredbg)