[CMake] Use target oriented design for bmalloc
[WebKit-https.git] / Source / bmalloc / CMakeLists.txt
1 set_property(DIRECTORY . PROPERTY FOLDER "bmalloc")
2
3 set(bmalloc_PRIVATE_INCLUDE_DIRECTORIES
4     "${BMALLOC_DIR}"
5 )
6
7 set(bmalloc_SOURCES
8     bmalloc/AllIsoHeaps.cpp
9     bmalloc/Allocator.cpp
10     bmalloc/AvailableMemory.cpp
11     bmalloc/Cache.cpp
12     bmalloc/CryptoRandom.cpp
13     bmalloc/Deallocator.cpp
14     bmalloc/DebugHeap.cpp
15     bmalloc/Environment.cpp
16     bmalloc/FreeList.cpp
17     bmalloc/Gigacage.cpp
18     bmalloc/Heap.cpp
19     bmalloc/HeapKind.cpp
20     bmalloc/IsoHeapImpl.cpp
21     bmalloc/IsoPage.cpp
22     bmalloc/IsoSharedHeap.cpp
23     bmalloc/IsoSharedPage.cpp
24     bmalloc/IsoTLS.cpp
25     bmalloc/IsoTLSEntry.cpp
26     bmalloc/IsoTLSLayout.cpp
27     bmalloc/LargeMap.cpp
28     bmalloc/Logging.cpp
29     bmalloc/Mutex.cpp
30     bmalloc/ObjectType.cpp
31     bmalloc/PerProcess.cpp
32     bmalloc/PerThread.cpp
33     bmalloc/Scavenger.cpp
34     bmalloc/VMHeap.cpp
35     bmalloc/bmalloc.cpp
36     bmalloc/mbmalloc.cpp
37 )
38
39 set(bmalloc_PUBLIC_HEADERS
40     bmalloc/Algorithm.h
41     bmalloc/AllIsoHeaps.h
42     bmalloc/AllIsoHeapsInlines.h
43     bmalloc/Allocator.h
44     bmalloc/AvailableMemory.h
45     bmalloc/BAssert.h
46     bmalloc/BCompiler.h
47     bmalloc/BExport.h
48     bmalloc/BInline.h
49     bmalloc/BMalloced.h
50     bmalloc/BPlatform.h
51     bmalloc/BVMTags.h
52     bmalloc/Bits.h
53     bmalloc/BulkDecommit.h
54     bmalloc/BumpAllocator.h
55     bmalloc/BumpRange.h
56     bmalloc/Cache.h
57     bmalloc/Chunk.h
58     bmalloc/CryptoRandom.h
59     bmalloc/Deallocator.h
60     bmalloc/DebugHeap.h
61     bmalloc/DeferredDecommit.h
62     bmalloc/DeferredDecommitInlines.h
63     bmalloc/DeferredTrigger.h
64     bmalloc/DeferredTriggerInlines.h
65     bmalloc/EligibilityResult.h
66     bmalloc/EligibilityResultInlines.h
67     bmalloc/Environment.h
68     bmalloc/FixedVector.h
69     bmalloc/FreeList.h
70     bmalloc/FreeListInlines.h
71     bmalloc/Gigacage.h
72     bmalloc/Heap.h
73     bmalloc/HeapKind.h
74     bmalloc/IsoAllocator.h
75     bmalloc/IsoAllocatorInlines.h
76     bmalloc/IsoConfig.h
77     bmalloc/IsoDeallocator.h
78     bmalloc/IsoDeallocatorInlines.h
79     bmalloc/IsoDirectory.h
80     bmalloc/IsoDirectoryInlines.h
81     bmalloc/IsoDirectoryPage.h
82     bmalloc/IsoDirectoryPageInlines.h
83     bmalloc/IsoHeap.h
84     bmalloc/IsoHeapImpl.h
85     bmalloc/IsoHeapImplInlines.h
86     bmalloc/IsoHeapInlines.h
87     bmalloc/IsoPage.h
88     bmalloc/IsoPageInlines.h
89     bmalloc/IsoPageTrigger.h
90     bmalloc/IsoSharedConfig.h
91     bmalloc/IsoSharedHeap.h
92     bmalloc/IsoSharedHeapInlines.h
93     bmalloc/IsoSharedPage.h
94     bmalloc/IsoSharedPageInlines.h
95     bmalloc/IsoTLS.h
96     bmalloc/IsoTLSAllocatorEntry.h
97     bmalloc/IsoTLSAllocatorEntryInlines.h
98     bmalloc/IsoTLSDeallocatorEntry.h
99     bmalloc/IsoTLSDeallocatorEntryInlines.h
100     bmalloc/IsoTLSEntry.h
101     bmalloc/IsoTLSEntryInlines.h
102     bmalloc/IsoTLSInlines.h
103     bmalloc/IsoTLSLayout.h
104     bmalloc/LargeMap.h
105     bmalloc/LargeRange.h
106     bmalloc/LineMetadata.h
107     bmalloc/List.h
108     bmalloc/Logging.h
109     bmalloc/Map.h
110     bmalloc/Mutex.h
111     bmalloc/Object.h
112     bmalloc/ObjectType.h
113     bmalloc/PerHeapKind.h
114     bmalloc/PerProcess.h
115     bmalloc/PerThread.h
116     bmalloc/PhysicalPageMap.h
117     bmalloc/ProcessCheck.h
118     bmalloc/Range.h
119     bmalloc/Scavenger.h
120     bmalloc/ScopeExit.h
121     bmalloc/Sizes.h
122     bmalloc/SmallLine.h
123     bmalloc/SmallPage.h
124     bmalloc/StaticPerProcess.h
125     bmalloc/StdLibExtras.h
126     bmalloc/Syscall.h
127     bmalloc/VMAllocate.h
128     bmalloc/VMHeap.h
129     bmalloc/Vector.h
130     bmalloc/Zone.h
131     bmalloc/bmalloc.h
132 )
133
134 if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
135     list(APPEND bmalloc_SOURCES
136         bmalloc/Zone.cpp
137     )
138 endif ()
139
140 set(bmalloc_LIBRARIES
141     ${CMAKE_DL_LIBS}
142 )
143
144 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
145
146 WEBKIT_WRAP_SOURCELIST(${bmalloc_SOURCES})
147
148 add_library(bmalloc STATIC ${bmalloc_SOURCES})
149 target_include_directories(bmalloc PRIVATE ${bmalloc_PRIVATE_INCLUDE_DIRECTORIES})
150 target_include_directories(bmalloc INTERFACE "$<BUILD_INTERFACE:${bmalloc_FRAMEWORK_HEADERS_DIR}>")
151 target_link_libraries(bmalloc ${bmalloc_LIBRARIES})
152 set_target_properties(bmalloc PROPERTIES COMPILE_DEFINITIONS "BUILDING_bmalloc")
153
154 WEBKIT_COPY_FILES(bmalloc_CopyHeaders
155     DESTINATION ${bmalloc_FRAMEWORK_HEADERS_DIR}
156     FILES ${bmalloc_PUBLIC_HEADERS}
157 )
158
159 add_library(bmalloc_PostBuild INTERFACE)
160 target_link_libraries(bmalloc_PostBuild INTERFACE bmalloc)
161 add_dependencies(bmalloc_PostBuild bmalloc_CopyHeaders)
162
163 add_library(WebKit::bmalloc ALIAS bmalloc_PostBuild)
164
165 if (DEVELOPER_MODE)
166     add_library(mbmalloc SHARED bmalloc/mbmalloc.cpp)
167     target_include_directories(mbmalloc PRIVATE ${bmalloc_PRIVATE_INCLUDE_DIRECTORIES})
168     target_link_libraries(mbmalloc bmalloc ${CMAKE_THREAD_LIBS_INIT} ${bmalloc_LIBRARIES})
169     set_target_properties(mbmalloc PROPERTIES COMPILE_DEFINITIONS "BUILDING_mbmalloc")
170 endif ()