aboutsummaryrefslogtreecommitdiff
path: root/ports/bdwgc/001-install-libraries.patch
blob: 2cc87f5be1fdc28c36cc7a4b981392b21ce78d70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8d386ca5..b94d6358 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,10 @@ include(CTest)
 
 cmake_minimum_required(VERSION 3.1)
 
+# Customize CMake options by passing "-D<OPTION_NAME>=ON|OFF" in your command line
+option(build_cord "Install cord" ON)
+option(build_tests "Install library tests" ON)
+option(install_headers "Install header files" ON)
 option(enable_threads "TODO" OFF) #TODO Support it
 option(enable_parallel_mark "Parallelize marking and free list construction" ON)
 option(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON)
@@ -52,22 +56,13 @@ add_definitions("-DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION")
 
 if (APPLE)
   if ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
-    set(CMAKE_OSX_ARCHITECTURES "ppc;i386;x86_64"
+    set(CMAKE_OSX_ARCHITECTURES "x86_64;i386"
         CACHE STRING "Build architectures for Mac OS X" FORCE)
   endif()
-elseif (WIN32)
+elseif (MSVC)
   add_definitions("-D_CRT_SECURE_NO_DEPRECATE")
 endif()
 
-#LIBATOMIC #TODO
-#ADD_LIBRARY(atomic_ops STATIC )
-#SET_TARGET_PROPERTIES(atomic_ops PROPERTIES COMPILE_FLAGS -DNO_DEBUGGING)
-
-
-#LIBGC
-
-include_directories(include)
-include_directories(libatomic_ops/src)
 
 set(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c
         mark_rts.c headers.c mark.c obj_map.c blacklst.c finalize.c
@@ -82,12 +77,6 @@ if (enable_threads)
   set(LIBS ${LIBS} ${Threads_LIBRARIES})
 endif()
 
-#IF(Threads_FOUND)
-#       ADD_DEFINITIONS("")
-#ELSE
-#       MESSAGE("Parallel mark requires enable_threads ON" )
-#ENDIF(Threads_FOUND)
-
 if (enable_cplusplus)
   set(SRC ${SRC} gc_cpp.cc)
 endif()
@@ -141,7 +130,7 @@ if (CMAKE_USE_PTHREADS_INIT)
       if (enable_parallel_mark)
         add_definitions("-DHANDLE_FORK")
       endif()
-    endif(enable_handle_fork)
+    endif()
     set(SRC ${SRC} darwin_stop_world.c)
     #TODO darwin_threads=true
   endif()
@@ -158,10 +147,10 @@ if (CMAKE_USE_WIN32_THREADS_INIT)
       add_definitions("-DTHREAD_LOCAL_ALLOC")
       set(SRC ${SRC} thread_local_alloc.c)
     endif()
-  endif(enable_parallel_mark)
+  endif()
   add_definitions("-DEMPTY_GETENV_RESULTS")
   set(SRC ${SRC} win32_threads.c)
-endif(CMAKE_USE_WIN32_THREADS_INIT)
+endif()
 
 if (enable_gcj_support)
   add_definitions("-DGC_GCJ_SUPPORT")
@@ -169,7 +158,7 @@ if (enable_gcj_support)
     add_definitions("-DGC_ENABLE_SUSPEND_THREAD")
   endif()
   set(SRC ${SRC} gcj_mlc.c)
-endif(enable_gcj_support)
+endif()
 
 if (enable_disclaim)
   add_definitions("-DENABLE_DISCLAIM")
@@ -195,7 +184,7 @@ if (enable_gc_debug)
     add_definitions("-DMAKE_BACK_GRAPH")
     set(SRC ${SRC} backgraph.c)
   endif()
-endif(enable_gc_debug)
+endif()
 
 if (enable_redirect_malloc)
   if (enable_gc_debug)
@@ -206,7 +195,7 @@ if (enable_redirect_malloc)
     add_definitions("-DREDIRECT_MALLOC=GC_malloc")
   endif()
   add_definitions("-DGC_USE_DLOPEN_WRAP")
-endif(enable_redirect_malloc)
+endif()
 
 if (enable_munmap)
   add_definitions("-DUSE_MMAP -DUSE_MUNMAP")
@@ -240,19 +229,44 @@ if (enable_checksums)
   endif()
   add_definitions("-DCHECKSUMS")
   set(SRC ${SRC} checksums.c)
-endif(enable_checksums)
-
-add_library(gc-lib STATIC ${SRC})
-set_target_properties(gc-lib PROPERTIES
-                      COMPILE_DEFINITIONS GC_NOT_DLL)
-#TODO TARGET_LINK_LIBRARIES(...  ...  ${LIBS})
+endif()
 
-add_library(gcmt-lib STATIC ${SRC})
-set_target_properties(gcmt-lib PROPERTIES
-                      COMPILE_DEFINITIONS GC_NOT_DLL)
+# Create target
+add_library(gc ${SRC})
+target_include_directories(gc  
+    PUBLIC     
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+        $<INSTALL_INTERFACE:include>
+)
+if (NOT BUILD_SHARED_LIBS)
+    target_compile_definitions(gc PRIVATE GC_NOT_DLL)
+else()
+    target_compile_definitions(gc PRIVATE GC_DLL)
+endif()
 
-add_library(gcmt-dll SHARED ${SRC})
+# Install library
+install(
+    TARGETS gc
+    EXPORT gcExports
+    LIBRARY DESTINATION lib 
+    ARCHIVE DESTINATION lib
+    RUNTIME DESTINATION bin 
+    INCLUDES DESTINATION include
+)
+
+# Install headers
+if (install_headers)
+    file(GLOB BDWGC_HEADERS "include/*.h")
+    install(FILES ${BDWGC_HEADERS} DESTINATION include/gc)
+
+    file(GLOB BDWGC_EXTRA_HEADERS "include/extra/*.h")
+    install(FILES ${BDWGC_EXTRA_HEADERS} DESTINATION include)
+endif()
 
-add_subdirectory(cord)
+if (build_cord)
+  add_subdirectory(cord)
+endif()
 
-add_subdirectory(tests)
+if (build_tests)
+  add_subdirectory(tests)
+endif()
diff --git a/cord/CMakeLists.txt b/cord/CMakeLists.txt
index 17077370..21818d4e 100644
--- a/cord/CMakeLists.txt
+++ b/cord/CMakeLists.txt
@@ -11,11 +11,11 @@
 # modified is included with the above copyright notice.
 ##
 
+add_executable(cord cordbscs.c cordxtra.c tests/de.c tests/de_win.c)
+set_target_properties(cord PROPERTIES COMPILE_DEFINITIONS GC_NOT_DLL)
+target_link_libraries(cord PRIVATE gc)
+
 if (WIN32)
-  add_executable(cord cordbscs.c cordxtra.c
-                 tests/de.c tests/de_win.c)
   set_target_properties(cord PROPERTIES WIN32_EXECUTABLE TRUE)
-  set_target_properties(cord PROPERTIES COMPILE_DEFINITIONS GC_NOT_DLL)
-  target_link_libraries(cord gc-lib)
-  target_link_libraries(cord gdi32)
+  target_link_libraries(cord PRIVATE gdi32)
 endif()
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c6bcc7d7..32a021e7 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -14,8 +14,6 @@
 # modified is included with the above copyright notice.
 ##
 
-add_definitions("-DGC_NOT_DLL")
-
 # Compile some tests as C++ to test extern "C" in header files.
 if (enable_cplusplus)
   set_source_files_properties(leak_test.c test.c
@@ -23,51 +21,51 @@ if (enable_cplusplus)
 endif()
 
 add_executable(gctest WIN32 test.c)
-target_link_libraries(gctest gc-lib)
+target_link_libraries(gctest PRIVATE gc)
 add_test(NAME gctest COMMAND gctest)
 
 add_executable(hugetest huge_test.c)
-target_link_libraries(hugetest gc-lib)
+target_link_libraries(hugetest PRIVATE gc)
 add_test(NAME hugetest COMMAND hugetest)
 
 add_executable(leaktest leak_test.c)
-target_link_libraries(leaktest gc-lib)
+target_link_libraries(leaktest PRIVATE gc)
 add_test(NAME leaktest COMMAND leaktest)
 
 add_executable(middletest middle.c)
-target_link_libraries(middletest gc-lib)
+target_link_libraries(middletest PRIVATE gc)
 add_test(NAME middletest COMMAND middletest)
 
 add_executable(realloc_test realloc_test.c)
-target_link_libraries(realloc_test gc-lib)
+target_link_libraries(realloc_test PRIVATE gc)
 add_test(NAME realloc_test COMMAND realloc_test)
 
 add_executable(smashtest smash_test.c)
-target_link_libraries(smashtest gc-lib)
+target_link_libraries(smashtest PRIVATE gc)
 add_test(NAME smashtest COMMAND smashtest)
 
 if (enable_gc_debug)
   add_executable(tracetest trace_test.c)
-  target_link_libraries(tracetest gc-lib)
+  target_link_libraries(tracetest PRIVATE gc)
   add_test(NAME tracetest COMMAND tracetest)
 endif()
 
 if (enable_cplusplus)
   # TODO add_executable(test_cpp test_cpp.cc)
-  # target_link_libraries(test_cpp gc-lib)
+  # target_link_libraries(test_cpp PRIVATE gc)
   # add_test(NAME test_cpp COMMAND test_cpp)
 endif()
 
 if (enable_disclaim)
   add_executable(disclaim_bench disclaim_bench.c)
-  target_link_libraries(disclaim_bench gc-lib)
+  target_link_libraries(disclaim_bench PRIVATE gc)
   add_test(NAME disclaim_bench COMMAND disclaim_bench)
 
   add_executable(disclaim_test disclaim_test.c)
-  target_link_libraries(disclaim_test gc-lib)
+  target_link_libraries(disclaim_test PRIVATE gc)
   add_test(NAME disclaim_test COMMAND disclaim_test)
 
   add_executable(disclaim_weakmap_test disclaim_weakmap_test.c)
-  target_link_libraries(disclaim_weakmap_test gc-lib)
+  target_link_libraries(disclaim_weakmap_test PRIVATE gc)
   add_test(NAME disclaim_weakmap_test COMMAND disclaim_weakmap_test)
 endif()