Update CMake files for Windows build
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Wed, 22 Aug 2018 15:18:37 +0000 (18:18 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Fri, 24 Aug 2018 15:36:22 +0000 (18:36 +0300)
CMakeLists.txt
src/debug/netcoredbg/CMakeLists.txt

index 6e611ca..d3127bd 100644 (file)
@@ -4,13 +4,30 @@ project(netcoredbg)
 set(CLR_DIR "${CMAKE_SOURCE_DIR}/../coreclr" CACHE FILEPATH "Path to coreclr directory")
 set(CLR_BIN_DIR "" CACHE FILEPATH "Path to coreclr bin directory")
 set(BUILD_MANAGED ON CACHE BOOL "Build managed part")
-set(DBGSHIM_INSTALL ON CACHE BOOL "Install libdbgshim")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-null-conversion")
+set(DBGSHIM_INSTALL ON CACHE BOOL "Install dbgshim library")
+if (WIN32)
+    set(CMAKE_CXX_STANDARD 11)
+else()
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-null-conversion")
+endif()
 
 function(clr_unknown_arch)
     message(FATAL_ERROR "Only AMD64, ARM64, ARM, ARMEL, I386 and WASM are supported")
 endfunction()
 
+if (WIN32)
+    # For windows it is expected that CLR_CMAKE_HOST_ARCH parameter is passed
+    # to CMAKE to determine build arch.
+    # If it is not passed, detect arch here.
+    if ("${CLR_CMAKE_HOST_ARCH}" STREQUAL "")
+        if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
+            set(CLR_CMAKE_HOST_ARCH x86)
+        else()
+            set(CLR_CMAKE_HOST_ARCH x64)
+        endif()
+    endif()
+endif()
+
 # Follow order as in root CoreCLR CMakeLists.txt
 include(detectplatform.cmake) # from root
 include(platformdefinitions.cmake) # from root
@@ -24,7 +41,9 @@ endif()
 set(CLR_CONFIGURATION_TYPES "Debug;Checked;Release;RelWithDebInfo" CACHE STRING "")
 
 if ("${CLR_BIN_DIR}" STREQUAL "")
-    if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
+    if (WIN32)
+        set(TARGET_OS_NAME "Windows_NT")
+    elseif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
         set(TARGET_OS_NAME "OSX")
     elseif (CMAKE_SYSTEM_NAME STREQUAL Linux)
         set(TARGET_OS_NAME "Linux")
index e069a92..dd156ee 100644 (file)
@@ -10,10 +10,12 @@ set_target_properties(dbgshim PROPERTIES IMPORTED_LOCATION ${DBGSHIM_LOCATION})
 add_library(corguids STATIC IMPORTED)
 set_target_properties(corguids PROPERTIES IMPORTED_LOCATION ${CLR_BIN_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}corguids${CMAKE_STATIC_LIBRARY_SUFFIX})
 
+if (NOT WIN32)
+    include_directories(${CLR_DIR}/src/pal/inc)
+    include_directories(${CLR_DIR}/src/pal/inc/rt)
+    include_directories(${CLR_DIR}/src/pal/prebuilt/inc)
+endif()
 include_directories(${CLR_DIR}/src/inc)
-include_directories(${CLR_DIR}/src/pal/inc)
-include_directories(${CLR_DIR}/src/pal/inc/rt)
-include_directories(${CLR_DIR}/src/pal/prebuilt/inc)
 include_directories(${CLR_DIR}/src/debug/inc)
 include_directories(${CLR_DIR}/src/debug/shim)
 include_directories(${CLR_DIR}/src/dlls/dbgshim)
@@ -54,11 +56,17 @@ else()
   endif()
 endif()
 
-add_definitions(-DPAL_STDCPP_COMPAT)
+if (NOT WIN32)
+    add_definitions(-DPAL_STDCPP_COMPAT)
+endif()
 
 add_executable(netcoredbg ${netcoredbg_SRC})
 
-target_link_libraries(netcoredbg corguids dbgshim dl pthread)
+if (WIN32)
+    target_link_libraries(netcoredbg corguids)
+else()
+    target_link_libraries(netcoredbg corguids dl pthread)
+endif()
 
 install(TARGETS netcoredbg DESTINATION ${CMAKE_INSTALL_PREFIX})
 if (DBGSHIM_INSTALL)