mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-25 05:38:59 +08:00
99825d9ebf
* [bdwgc] New port * [bdwgc] Fix x64-windows-static build * [bdwgc] Patch CMakeLists.txt to install libraries * [bdwgc] Rename produced binaries to <PREFIX>gc<SUFFIX> * [bdwgc] Export library symbols using GC_DLL * [bdwgc] Disable installation of extra tools * [bdwgc] Fix installation path for header files * [bdwgc] Use latest commit and CMake patch * [bdwgc] Update patch * [bdwgc] Disable tests and cord * [bdwgc] Use local patch * [bdwgc] Remove unsupported MacOS architecture
257 lines
7.7 KiB
Diff
257 lines
7.7 KiB
Diff
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()
|
|
|