1#add_subdirectory(arm64)
2#add_subdirectory(arm)
3add_subdirectory(i386)
4#add_subdirectory(ppc)
5add_subdirectory(x86_64)
6
7include_directories(..)
8
9set(generated_mach_interfaces
10  ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
11  ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
12  ${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c
13  )
14add_custom_command(OUTPUT ${generated_mach_interfaces}
15  COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/dbgnub-mig.defs
16  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dbgnub-mig.defs
17  )
18
19set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
20set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
21
22add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE}
23  COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
24          ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj debugserver
25          > ${DEBUGSERVER_VERS_GENERATED_FILE}
26  DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
27          ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj
28  )
29
30set(DEBUGSERVER_USED_LIBS
31  lldbDebugserverCommon
32  lldbUtility
33  lldbDebugserverMacOSX_I386
34  lldbDebugserverMacOSX_X86_64
35  )
36
37add_lldb_executable(debugserver
38  HasAVX.s
39  CFBundle.cpp
40  CFData.cpp
41  CFString.cpp
42  Genealogy.cpp
43  MachException.cpp
44  MachProcess.mm
45  MachTask.mm
46  MachThread.cpp
47  MachThreadList.cpp
48  MachVMMemory.cpp
49  MachVMRegion.cpp
50  ${generated_mach_interfaces}
51  ${DEBUGSERVER_VERS_GENERATED_FILE}
52  )
53
54set_source_files_properties(
55  HasAVX.s
56  # Necessary since compilation will fail with stand-alone assembler
57  PROPERTIES LANGUAGE C COMPILE_FLAGS "-x assembler-with-cpp"
58  )
59
60target_link_libraries(debugserver ${DEBUGSERVER_USED_LIBS})
61
62# Sign the debugserver binary
63set (CODESIGN_IDENTITY lldb_codesign)
64execute_process(
65  COMMAND xcrun -f codesign_allocate
66  OUTPUT_STRIP_TRAILING_WHITESPACE
67  OUTPUT_VARIABLE CODESIGN_ALLOCATE
68  )
69# Older cmake versions don't support "-E env".
70if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 3.2)
71  add_custom_command(TARGET debugserver
72    POST_BUILD
73    # Note: --entitlements option removed, as it causes errors when debugging.
74    # was: COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign --entitlements ${CMAKE_CURRENT_SOURCE_DIR}/../debugserver-entitlements.plist --force --sign ${CODESIGN_IDENTITY} debugserver
75    COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign --force --sign ${CODESIGN_IDENTITY} debugserver
76    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
77  )
78else()
79  add_custom_command(TARGET debugserver
80    POST_BUILD
81    # Note: --entitlements option removed (see comment above).
82    COMMAND ${CMAKE_COMMAND} -E env CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign --force --sign ${CODESIGN_IDENTITY} debugserver
83    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
84  )
85endif()
86
87install(TARGETS debugserver
88  RUNTIME DESTINATION bin
89  )
90