CMakeLists.txt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. set(ch_source_files
  2. ch.cpp
  3. ChakraRtInterface.cpp
  4. CodexAssert.cpp
  5. Debugger.cpp
  6. Helpers.cpp
  7. HostConfigFlags.cpp
  8. WScriptJsrt.cpp
  9. )
  10. if (STATIC_LIBRARY)
  11. set(ch_source_files "${ch_source_files}"
  12. ../ChakraCore/TestHooks.cpp
  13. )
  14. endif()
  15. add_executable (ch ${ch_source_files})
  16. set_target_properties(ch
  17. PROPERTIES
  18. POSITION_INDEPENDENT_CODE True
  19. )
  20. include_directories(..)
  21. target_include_directories (ch
  22. PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  23. ../ChakraCore
  24. ../../lib/Common
  25. ../../lib/Jsrt
  26. )
  27. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE")
  28. if(CMAKE_SYSTEM_NAME STREQUAL Linux)
  29. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") # osx clang sets this by default
  30. endif()
  31. if(STATIC_LIBRARY)
  32. if(CMAKE_SYSTEM_NAME STREQUAL Linux)
  33. set(lib_target
  34. -Wl,--no-undefined
  35. -Wl,--start-group
  36. -Wl,--whole-archive
  37. Chakra.Jsrt
  38. Chakra.Jsrt.Core
  39. -Wl,--no-whole-archive
  40. )
  41. elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
  42. set(lib_target
  43. -Wl,-undefined,error
  44. Chakra.Jsrt
  45. Chakra.Jsrt.Core
  46. )
  47. else()
  48. message("This platform is not yet supported")
  49. endif() # Linux ?
  50. # make sure to include Common.Core before others
  51. # this will help linker on some platforms for correct
  52. # initialization order
  53. set(lib_target "${lib_target}"
  54. Chakra.Common.Core
  55. )
  56. # common link deps
  57. set(lib_target "${lib_target}"
  58. Chakra.Runtime.Types
  59. Chakra.Runtime.Math
  60. Chakra.Runtime.Library
  61. Chakra.Runtime.Language
  62. Chakra.Runtime.Debug
  63. Chakra.Runtime.ByteCode
  64. Chakra.Runtime.PlatformAgnostic
  65. Chakra.Runtime.Base
  66. Chakra.Parser
  67. Chakra.Common.Util
  68. Chakra.Common.Memory
  69. Chakra.Common.Common
  70. Chakra.Common.DataStructures
  71. Chakra.Common.Exceptions
  72. Chakra.Common.Codex
  73. )
  74. if(CMAKE_SYSTEM_NAME STREQUAL Linux)
  75. set(lib_target "${lib_target}"
  76. -Wl,--end-group
  77. Chakra.Pal
  78. pthread
  79. stdc++
  80. dl
  81. icuuc
  82. )
  83. elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
  84. set(lib_target "${lib_target}"
  85. Chakra.Pal
  86. pthread
  87. stdc++
  88. dl
  89. icucore
  90. )
  91. endif() # Linux ?
  92. else() # // !from shared library
  93. set(lib_target
  94. PRIVATE Chakra.Pal
  95. PRIVATE Chakra.Common.Codex
  96. PRIVATE Chakra.Runtime.PlatformAgnostic
  97. )
  98. endif()
  99. if(CMAKE_SYSTEM_NAME STREQUAL Linux)
  100. set(lib_target "${lib_target}"
  101. -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/ch.version
  102. )
  103. endif()
  104. target_link_libraries (ch ${lib_target})
  105. if(NOT CC_XCODE_PROJECT)
  106. # Add a post build event to the ch target
  107. # which executes a command to copy ch to
  108. # BuildLinux for convenience
  109. add_custom_command(TARGET ch POST_BUILD
  110. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  111. "${CHAKRACORE_BINARY_DIR}/bin/ch/ch"
  112. ${CHAKRACORE_BINARY_DIR}/)
  113. endif()