# this will generate gc.sln
#
-SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
+set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
-PROJECT(gc)
+project(gc)
-INCLUDE(CTest)
+include(CTest)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+cmake_minimum_required(VERSION 2.6)
-ADD_DEFINITIONS("-D_CRT_SECURE_NO_DEPRECATE
- -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION")
+add_definitions("-D_CRT_SECURE_NO_DEPRECATE")
+add_definitions("-DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION")
-IF(APPLE)
- IF("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
- SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;x86_64" CACHE STRING "Build architectures for Mac OS X" FORCE)
- ENDIF()
-ENDIF(APPLE)
+if (APPLE)
+ if ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
+ set(CMAKE_OSX_ARCHITECTURES "ppc;i386;x86_64"
+ CACHE STRING "Build architectures for Mac OS X" FORCE)
+ endif()
+endif(APPLE)
#LIBATOMIC #TODO
#ADD_LIBRARY(atomic_ops STATIC )
#LIBGC
-INCLUDE_DIRECTORIES(include)
-INCLUDE_DIRECTORIES(libatomic_ops/src)
+include_directories(include)
+include_directories(libatomic_ops/src)
-SET(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c
+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
new_hblk.c dbg_mlc.c malloc.c dyn_load.c typd_mlc.c ptr_chck.c
mallocx.c)
-SET(LIBS)
-OPTION(enable_threads "TODO" NO)
-IF(enable_threads)
- FIND_PACKAGE(Threads REQUIRED)
- MESSAGE("Thread Model: ${CMAKE_THREAD_LIBS_INIT}" )
- INCLUDE_DIRECTORIES(${Threads_INCLUDE_DIR})
- SET(LIBS ${LIBS} ${Threads_LIBRARIES})
-ENDIF(enable_threads)
+set(LIBS)
-OPTION(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON)
+option(enable_threads "TODO" NO)
+if (enable_threads)
+ find_package(Threads REQUIRED)
+ message("Thread Model: ${CMAKE_THREAD_LIBS_INIT}" )
+ include_directories(${Threads_INCLUDE_DIR})
+ set(LIBS ${LIBS} ${Threads_LIBRARIES})
+endif()
-OPTION(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON)
-
-OPTION(enable_parallel_mark "Parallelize marking and free list construction" ON)
+option(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON)
+option(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON)
+option(enable_parallel_mark "Parallelize marking and free list construction" ON)
#IF(Threads_FOUND)
# ADD_DEFINITIONS("")
#ENDIF(Threads_FOUND)
#OPTION(enable_cplusplus "install C++ support" ON)
-SET(SRC ${SRC} gc_cpp.cc)
+set(SRC ${SRC} gc_cpp.cc)
-SET(_HOST ${CMAKE_HOST_SYSTEM_PROCESSOR}--${CMAKE_SYSTEM}) #FIXME missing the vendor field.
-STRING(TOLOWER ${_HOST} HOST)
-MESSAGE("HOST = ${HOST}")
+set(_HOST ${CMAKE_HOST_SYSTEM_PROCESSOR}--${CMAKE_SYSTEM})
+ #FIXME missing the vendor field.
+string(TOLOWER ${_HOST} HOST)
+message("HOST = ${HOST}")
# Thread Detection. Relying on cmake for lib and includes.
#TODO check cmake detection
-IF(CMAKE_USE_PTHREADS_INIT)
- SET(SRC ${SRC} pthread_start.c pthread_support.c pthread_stop_world.c)
- # Common defines for most POSIX platforms.
- IF( HOST MATCHES .*-.*-aix.*|.*-.*-android.*|.*-.*-cygwin.*|.*-.*-darwin.*|.*-.*-.*freebsd.*|.*-.*-haiku.*|.*-.*-gnu.*|.*-.*-hpux11.*|.*-.*-irix.*|.*-.*-.*linux.*|.*-.*-msys.*|.*-.*-nacl.*|.*-.*-netbsd.*|.*-.*-openbsd.*|.*-.*-osf.*|.*-.*-solaris.*)
- ADD_DEFINITIONS("-DGC_THREADS -D_REENTRANT")
- IF(enable_parallel_mark)
- ADD_DEFINITIONS("-DPARALLEL_MARK")
- ENDIF(enable_parallel_mark)
- IF(enable_thread_local_alloc)
- ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC")
- SET(SRC ${SRC} thread_local_alloc.c)
- ENDIF(enable_thread_local_alloc)
- MESSAGE("Explicit GC_INIT() calls may be required.")
- ENDIF()
- IF ( HOST MATCHES .*-.*-hpux11.*)
- MESSAGE("Only HP/UX 11 POSIX threads are supported.")
- ADD_DEFINITIONS("-D_POSIX_C_SOURCE=199506L") #TODO test -DVAR=value. Alternative is COMPILE_DEFINITIONS property
- ENDIF()
- IF ( HOST MATCHES .*-.*-hpux10.*)
- MESSAGE("HP/UX 10 POSIX threads are not supported.")
- ENDIF()
- IF ( HOST MATCHES .*-.*-netbsd.*)
- MESSAGE("Only on NetBSD 2.0 or later.")
- ADD_DEFINITIONS("-D_PTHREADS")
- ENDIF()
- IF( HOST MATCHES .*-.*-android.*)
- # Android NDK does not provide pthread_atfork.
- ELSEIF( HOST MATCHES .*-.*-aix.*|.*-.*-cygwin.*|.*-.*-freebsd.*|.*-.*-haiku.*|.*-.*-hpux11.*|.*-.*-irix.*|.*-.*-kfreebsd.*-gnu|.*-.*-.*linux.*|.*-.*-netbsd.*|.*-.*-openbsd.*|.*-.*-osf.*|.*-.*-solaris.*)
- IF(enable_handle_fork)
- ADD_DEFINITIONS("-DHANDLE_FORK")
- ENDIF(enable_handle_fork)
- ENDIF()
- IF ( HOST MATCHES .*-.*-cygwin.*|.*-.*-msys.*)
- SET(SRC ${SRC} win32_threads.c)
- ENDIF()
- IF ( HOST MATCHES .*-.*-darwin.*)
- IF(enable_handle_fork)
- # The incremental mode conflicts with fork handling.
- IF(enable_parallel_mark)
- ADD_DEFINITIONS("-DHANDLE_FORK")
- ENDIF(enable_parallel_mark)
- ENDIF(enable_handle_fork)
- SET(SRC ${SRC} darwin_stop_world.c)
- #TODO
- #darwin_threads=true
- ENDIF()
-ENDIF(CMAKE_USE_PTHREADS_INIT)
-
-IF(CMAKE_USE_WIN32_THREADS_INIT)
- ADD_DEFINITIONS("-DGC_THREADS")
- IF(enable_parallel_mark)
- ADD_DEFINITIONS("-DPARALLEL_MARK")
- IF(enable_thread_local_alloc)
- ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC")
- SET(SRC ${SRC} thread_local_alloc.c)
- ENDIF(enable_thread_local_alloc)
- ENDIF()
- ADD_DEFINITIONS("-DEMPTY_GETENV_RESULTS") #TODO test
- SET(SRC ${SRC} win32_threads.c)
-ENDIF(CMAKE_USE_WIN32_THREADS_INIT)
-
-OPTION(enable_gcj_support "Support for gcj" ON)
-IF(enable_gcj_support)
- ADD_DEFINITIONS("-DGC_GCJ_SUPPORT")
- IF(enable_threads)
- ADD_DEFINITIONS("-DGC_ENABLE_SUSPEND_THREAD")
- ENDIF(enable_threads)
- SET(SRC ${SRC} gcj_mlc.c)
-ENDIF(enable_gcj_support)
-
-OPTION(enable_disclaim "Support alternative finalization interface" ON)
-IF(enable_disclaim)
- ADD_DEFINITIONS("-DENABLE_DISCLAIM")
- SET(SRC ${SRC} fnlz_mlc.c)
-ENDIF(enable_disclaim)
-
-OPTION(enable_java_finalization "Support for java finalization" ON)
-IF(enable_java_finalization)
- ADD_DEFINITIONS("-DJAVA_FINALIZATION")
-ENDIF(enable_java_finalization)
-
-OPTION(enable_atomic_uncollectable "Support for atomic uncollectible allocation" ON)
-IF(enable_atomic_uncollectable)
- ADD_DEFINITIONS("-DGC_ATOMIC_UNCOLLECTABLE")
-ENDIF(enable_atomic_uncollectable)
-
-OPTION(enable_gc_debug "Support for pointer back-tracing" NO)
-IF(enable_gc_debug)
- ADD_DEFINITIONS("-DDBG_HDRS_ALL -DKEEP_BACK_PTRS")
- IF (HOST MATCHES ia64-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86-.*-linux.*|x86_64-.*-linux.*)
- ADD_DEFINITIONS("-DMAKE_BACK_GRAPH")
- ADD_DEFINITIONS("-DSAVE_CALL_COUNT=8")
- SET(SRC ${SRC} backgraph.c)
- ENDIF()
- IF (HOST MATCHES i.86-.*-dgux.*)
- ADD_DEFINITIONS("-DMAKE_BACK_GRAPH")
- SET(SRC ${SRC} backgraph.c)
- ENDIF()
-ENDIF(enable_gc_debug)
-
-OPTION(enable_redirect_malloc "Redirect malloc and friends to GC routines" NO)
-IF(enable_redirect_malloc)
- IF(enable_gc_debug)
- ADD_DEFINITIONS("-DREDIRECT_MALLOC=GC_debug_malloc_replacement")
- ADD_DEFINITIONS("-DREDIRECT_REALLOC=GC_debug_realloc_replacement")
- ADD_DEFINITIONS("-DREDIRECT_FREE=GC_debug_free")
- ELSE(enable_gc_debug)
- ADD_DEFINITIONS("-DREDIRECT_MALLOC=GC_malloc")
- ENDIF(enable_gc_debug)
- ADD_DEFINITIONS("-DGC_USE_DLOPEN_WRAP")
-ENDIF(enable_redirect_malloc)
-
-OPTION(enable_mmap "Use mmap instead of sbrk to expand the heap" NO)
-
-OPTION(enable_munmap "Return page to the OS if empty for N collections" ON)
-IF(enable_munmap)
- ADD_DEFINITIONS("-DUSE_MMAP -DUSE_MUNMAP")
-ELSEIF(enable_mmap)
- ADD_DEFINITIONS("-DUSE_MMAP")
-ENDIF()
-
-OPTION(enable_dynamic_loading "Enable tracing of dynamic library data roots" ON)
-IF(NOT enable_dynamic_loading)
- ADD_DEFINITIONS("-DIGNORE_DYNAMIC_LOADING")
-ENDIF()
-
-OPTION(enable_register_main_static_data "Perform the initial guess of data root sets" ON)
-IF(NOT enable_register_main_static_data)
- ADD_DEFINITIONS("-DGC_DONT_REGISTER_MAIN_STATIC_DATA")
-ENDIF()
-
-OPTION(enable_large_config "Optimize for large heap or root set" NO)
-IF(enable_large_config)
- ADD_DEFINITIONS("-DLARGE_CONFIG")
-ENDIF(enable_large_config)
-
-OPTION(enable_gc_assertions "Enable collector-internal assertion checking" NO)
-IF(enable_gc_assertions)
- ADD_DEFINITIONS("-DGC_ASSERTIONS")
-ENDIF(enable_gc_assertions)
-
-OPTION(enable_threads_discovery "Enable threads discovery in GC" ON)
-IF(NOT enable_threads_discovery)
- ADD_DEFINITIONS("-DGC_NO_THREADS_DISCOVERY")
-ENDIF()
-
-OPTION(enable_checksums "Report erroneously cleared dirty bits" NO)
-IF(enable_checksums)
- IF(enable_munmap OR enable_threads)
- MESSAGE("CHECKSUMS not compatible with USE_MUNMAP or threads")
- ENDIF()
- ADD_DEFINITIONS("-DCHECKSUMS")
- SET(SRC ${SRC} checksums.c)
-ENDIF(enable_checksums)
-
-ADD_LIBRARY( gc-lib STATIC ${SRC})
-SET_TARGET_PROPERTIES(gc-lib PROPERTIES
+if (CMAKE_USE_PTHREADS_INIT)
+ set(SRC ${SRC} pthread_start.c pthread_support.c pthread_stop_world.c)
+ # Common defines for most POSIX platforms.
+ if (HOST MATCHES .*-.*-aix.*|.*-.*-android.*|.*-.*-cygwin.*|.*-.*-darwin.*|.*-.*-.*freebsd.*|.*-.*-haiku.*|.*-.*-gnu.*|.*-.*-hpux11.*|.*-.*-irix.*|.*-.*-.*linux.*|.*-.*-msys.*|.*-.*-nacl.*|.*-.*-netbsd.*|.*-.*-openbsd.*|.*-.*-osf.*|.*-.*-solaris.*)
+ add_definitions("-DGC_THREADS -D_REENTRANT")
+ if (enable_parallel_mark)
+ add_definitions("-DPARALLEL_MARK")
+ endif()
+ if (enable_thread_local_alloc)
+ add_definitions("-DTHREAD_LOCAL_ALLOC")
+ set(SRC ${SRC} thread_local_alloc.c)
+ endif()
+ message("Explicit GC_INIT() calls may be required.")
+ endif()
+ if (HOST MATCHES .*-.*-hpux11.*)
+ message("Only HP/UX 11 POSIX threads are supported.")
+ add_definitions("-D_POSIX_C_SOURCE=199506L")
+ #TODO test -DVAR=value. Alternative is COMPILE_DEFINITIONS property
+ endif()
+ if (HOST MATCHES .*-.*-hpux10.*)
+ message("HP/UX 10 POSIX threads are not supported.")
+ endif()
+ if (HOST MATCHES .*-.*-netbsd.*)
+ message("Only on NetBSD 2.0 or later.")
+ add_definitions("-D_PTHREADS")
+ endif()
+ if (HOST MATCHES .*-.*-android.*)
+ # Android NDK does not provide pthread_atfork.
+ elseif (HOST MATCHES .*-.*-aix.*|.*-.*-cygwin.*|.*-.*-freebsd.*|.*-.*-haiku.*|.*-.*-hpux11.*|.*-.*-irix.*|.*-.*-kfreebsd.*-gnu|.*-.*-.*linux.*|.*-.*-netbsd.*|.*-.*-openbsd.*|.*-.*-osf.*|.*-.*-solaris.*)
+ if (enable_handle_fork)
+ add_definitions("-DHANDLE_FORK")
+ endif(enable_handle_fork)
+ endif()
+ if (HOST MATCHES .*-.*-cygwin.*|.*-.*-msys.*)
+ set(SRC ${SRC} win32_threads.c)
+ endif()
+ if (HOST MATCHES .*-.*-darwin.*)
+ if (enable_handle_fork)
+ # The incremental mode conflicts with fork handling.
+ if (enable_parallel_mark)
+ add_definitions("-DHANDLE_FORK")
+ endif()
+ endif(enable_handle_fork)
+ set(SRC ${SRC} darwin_stop_world.c)
+ #TODO darwin_threads=true
+ endif()
+endif(CMAKE_USE_PTHREADS_INIT)
+
+if (CMAKE_USE_WIN32_THREADS_INIT)
+ add_definitions("-DGC_THREADS")
+ if (enable_parallel_mark)
+ add_definitions("-DPARALLEL_MARK")
+ if (enable_thread_local_alloc)
+ add_definitions("-DTHREAD_LOCAL_ALLOC")
+ set(SRC ${SRC} thread_local_alloc.c)
+ endif()
+ endif(enable_parallel_mark)
+ add_definitions("-DEMPTY_GETENV_RESULTS")
+ set(SRC ${SRC} win32_threads.c)
+endif(CMAKE_USE_WIN32_THREADS_INIT)
+
+option(enable_gcj_support "Support for gcj" ON)
+if (enable_gcj_support)
+ add_definitions("-DGC_GCJ_SUPPORT")
+ if (enable_threads)
+ add_definitions("-DGC_ENABLE_SUSPEND_THREAD")
+ endif()
+ set(SRC ${SRC} gcj_mlc.c)
+endif(enable_gcj_support)
+
+option(enable_disclaim "Support alternative finalization interface" ON)
+if (enable_disclaim)
+ add_definitions("-DENABLE_DISCLAIM")
+ set(SRC ${SRC} fnlz_mlc.c)
+endif()
+
+option(enable_java_finalization "Support for java finalization" ON)
+if (enable_java_finalization)
+ add_definitions("-DJAVA_FINALIZATION")
+endif()
+
+option(enable_atomic_uncollectable "Support for atomic uncollectible allocation" ON)
+if (enable_atomic_uncollectable)
+ add_definitions("-DGC_ATOMIC_UNCOLLECTABLE")
+endif()
+
+option(enable_gc_debug "Support for pointer back-tracing" NO)
+if (enable_gc_debug)
+ add_definitions("-DDBG_HDRS_ALL -DKEEP_BACK_PTRS")
+ if (HOST MATCHES ia64-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86-.*-linux.*|x86_64-.*-linux.*)
+ add_definitions("-DMAKE_BACK_GRAPH")
+ add_definitions("-DSAVE_CALL_COUNT=8")
+ set(SRC ${SRC} backgraph.c)
+ endif()
+ if (HOST MATCHES i.86-.*-dgux.*)
+ add_definitions("-DMAKE_BACK_GRAPH")
+ set(SRC ${SRC} backgraph.c)
+ endif()
+endif(enable_gc_debug)
+
+option(enable_redirect_malloc "Redirect malloc and friends to GC routines" NO)
+if (enable_redirect_malloc)
+ if (enable_gc_debug)
+ add_definitions("-DREDIRECT_MALLOC=GC_debug_malloc_replacement")
+ add_definitions("-DREDIRECT_REALLOC=GC_debug_realloc_replacement")
+ add_definitions("-DREDIRECT_FREE=GC_debug_free")
+ else()
+ add_definitions("-DREDIRECT_MALLOC=GC_malloc")
+ endif()
+ add_definitions("-DGC_USE_DLOPEN_WRAP")
+endif(enable_redirect_malloc)
+
+option(enable_mmap "Use mmap instead of sbrk to expand the heap" NO)
+
+option(enable_munmap "Return page to the OS if empty for N collections" ON)
+if (enable_munmap)
+ add_definitions("-DUSE_MMAP -DUSE_MUNMAP")
+elseif (enable_mmap)
+ add_definitions("-DUSE_MMAP")
+endif()
+
+option(enable_dynamic_loading "Enable tracing of dynamic library data roots" ON)
+if (NOT enable_dynamic_loading)
+ add_definitions("-DIGNORE_DYNAMIC_LOADING")
+endif()
+
+option(enable_register_main_static_data "Perform the initial guess of data root sets" ON)
+if (NOT enable_register_main_static_data)
+ add_definitions("-DGC_DONT_REGISTER_MAIN_STATIC_DATA")
+endif()
+
+option(enable_large_config "Optimize for large heap or root set" NO)
+if (enable_large_config)
+ add_definitions("-DLARGE_CONFIG")
+endif()
+
+option(enable_gc_assertions "Enable collector-internal assertion checking" NO)
+if (enable_gc_assertions)
+ add_definitions("-DGC_ASSERTIONS")
+endif()
+
+option(enable_threads_discovery "Enable threads discovery in GC" ON)
+if (NOT enable_threads_discovery)
+ add_definitions("-DGC_NO_THREADS_DISCOVERY")
+endif()
+
+option(enable_checksums "Report erroneously cleared dirty bits" NO)
+if (enable_checksums)
+ if (enable_munmap OR enable_threads)
+ message("CHECKSUMS not compatible with USE_MUNMAP or threads")
+ 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})
-ADD_LIBRARY( gcmt-lib STATIC ${SRC})
-SET_TARGET_PROPERTIES(gcmt-lib PROPERTIES
+add_library(gcmt-lib STATIC ${SRC})
+set_target_properties(gcmt-lib PROPERTIES
COMPILE_DEFINITIONS GC_NOT_DLL)
-ADD_LIBRARY( gcmt-dll SHARED ${SRC})
+add_library(gcmt-dll SHARED ${SRC})
-IF(WIN32)
- ADD_EXECUTABLE(cord cord/cordbscs.c cord/cordxtra.c
+if (WIN32)
+ add_executable(cord cord/cordbscs.c cord/cordxtra.c
cord/tests/de.c cord/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)
-ENDIF(WIN32)
+ 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)
+endif()
-ADD_SUBDIRECTORY(tests)
+add_subdirectory(tests)