2
0

CMakeLists.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. cmake_minimum_required(VERSION 3.2)
  2. project (CHAKRACORE)
  3. function(clr_unknown_arch)
  4. if (WIN32)
  5. message(FATAL_ERROR "Only AMD64, ARM and I386 are supported")
  6. else()
  7. message(FATAL_ERROR "Only AMD64 and ARM are supported")
  8. endif()
  9. endfunction()
  10. if(CMAKE_SYSTEM_NAME STREQUAL Linux)
  11. set(CLR_CMAKE_PLATFORM_UNIX 1)
  12. if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
  13. set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1)
  14. else()
  15. clr_unknown_arch()
  16. endif()
  17. set(CLR_CMAKE_PLATFORM_LINUX 1)
  18. elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
  19. set(CLR_CMAKE_PLATFORM_UNIX 1)
  20. if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
  21. set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1)
  22. else()
  23. clr_unknown_arch()
  24. endif()
  25. set(CLR_CMAKE_PLATFORM_DARWIN 1)
  26. else()
  27. clr_unknown_arch()
  28. endif()
  29. if(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64)
  30. set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1)
  31. endif()
  32. if (CMAKE_CXX_COMPILER_ID STREQUAL AppleClang
  33. OR CMAKE_CXX_COMPILER_ID STREQUAL Clang
  34. OR CMAKE_CXX_COMPILER_ID STREQUAL GNU)
  35. # Color diagnostics for g++ and clang++
  36. add_definitions("-fdiagnostics-color=always")
  37. endif()
  38. if(CLR_CMAKE_PLATFORM_UNIX)
  39. add_definitions(-DPLATFORM_UNIX=1)
  40. if(CLR_CMAKE_PLATFORM_LINUX)
  41. add_definitions(-D__LINUX__=1)
  42. if(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64)
  43. message("Detected Linux x86_64")
  44. add_definitions(-DLINUX64)
  45. else()
  46. clr_unknown_arch()
  47. endif(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64)
  48. endif(CLR_CMAKE_PLATFORM_LINUX)
  49. if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
  50. set(IS_64BIT_BUILD 1)
  51. add_definitions(-D_M_X64 -D_M_AMD64)
  52. endif(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
  53. add_definitions("-D__STDC_WANT_LIB_EXT1__=1")
  54. add_definitions(
  55. -DUNICODE
  56. -D_SAFECRT_USE_CPP_OVERLOADS=1
  57. )
  58. add_compile_options(-fms-extensions)
  59. # Disable some warnings
  60. add_compile_options(-Wno-tautological-constant-out-of-range-compare)
  61. set(CMAKE_CXX_STANDARD 11)
  62. # xplat-todo: enable the JIT for Linux
  63. add_definitions(
  64. -DDISABLE_JIT=1
  65. )
  66. # xplat-todo: revisit these
  67. # also, we should change this from add_definitions- the intent of that
  68. # is to just add -D flags
  69. add_definitions(
  70. -fdelayed-template-parsing
  71. -Wno-microsoft
  72. -Wno-unused-value
  73. -Wno-int-to-void-pointer-cast
  74. -Wno-invalid-offsetof
  75. -Wno-undefined-inline
  76. -Wno-inconsistent-missing-override
  77. -Wno-c++14-extensions
  78. -Wno-macro-redefined
  79. -Wno-ignored-pragmas
  80. -Wno-invalid-token-paste
  81. -Wno-format
  82. -Wno-invalid-noreturn
  83. -Wno-null-arithmetic
  84. -Wno-tautological-undefined-compare
  85. -Wno-address-of-temporary # vtinfo.h, VirtualTableInfo<T>::RegisterVirtualTable
  86. -Wno-null-conversion # Check shmemory.cpp and cs.cpp here...
  87. )
  88. endif(CLR_CMAKE_PLATFORM_UNIX)
  89. if(CMAKE_BUILD_TYPE STREQUAL Debug)
  90. add_definitions(
  91. -DDBG=1
  92. -DDEBUG=1
  93. -DDBG_DUMP=1
  94. )
  95. # xplat-todo: reenable this warning
  96. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-writable-strings")
  97. endif(CMAKE_BUILD_TYPE STREQUAL Debug)
  98. if(IS_64BIT_BUILD)
  99. add_definitions(
  100. -DBIT64=1
  101. -DSTACK_ALIGN=16
  102. )
  103. endif(IS_64BIT_BUILD)
  104. if(CLR_CMAKE_PLATFORM_UNIX)
  105. add_definitions(-DFEATURE_PAL)
  106. endif(CLR_CMAKE_PLATFORM_UNIX)
  107. enable_language(ASM)
  108. include_directories(
  109. .
  110. lib/Common
  111. lib/Common/PlaceHolder
  112. pal
  113. pal/inc
  114. pal/inc/rt
  115. )
  116. add_subdirectory (lib)
  117. add_subdirectory (bin)
  118. add_subdirectory (pal)