Add documentation, expand error handling, implement file and buffer io
This commit is contained in:
@@ -23,8 +23,9 @@ include(CTest)
|
||||
enable_testing()
|
||||
|
||||
# Set library code
|
||||
set(BHLIB_SOURCE
|
||||
set(BH_SOURCE
|
||||
src/algo.c
|
||||
src/buffer.c
|
||||
src/hashmap.c
|
||||
src/queue.c
|
||||
src/thread.c
|
||||
@@ -32,9 +33,10 @@ set(BHLIB_SOURCE
|
||||
src/deflate.c
|
||||
)
|
||||
|
||||
set(BHLIB_HEADER
|
||||
set(BH_HEADER
|
||||
include/bh/bh.h
|
||||
include/bh/platform.h
|
||||
include/bh/buffer.h
|
||||
include/bh/algo.h
|
||||
include/bh/hashmap.h
|
||||
include/bh/queue.h
|
||||
@@ -43,7 +45,7 @@ set(BHLIB_HEADER
|
||||
include/bh/deflate.h
|
||||
)
|
||||
|
||||
set(BHLIB_INCLUDE_DIRS
|
||||
set(BH_INCLUDE_DIRS
|
||||
include
|
||||
${PROJECT_BINARY_DIR}/include
|
||||
)
|
||||
@@ -52,45 +54,58 @@ set(BHLIB_INCLUDE_DIRS
|
||||
# Determine platform
|
||||
if(WIN32)
|
||||
message(STATUS "Platform - Win32")
|
||||
set(BH_PLATFORM_WIN TRUE)
|
||||
|
||||
# Add platform dependent files
|
||||
list(APPEND BH_SOURCE
|
||||
src/file_win.c
|
||||
)
|
||||
|
||||
# Check multithreading support
|
||||
check_symbol_exists(_beginthread process.h BHLIB_USE_WINTHREAD)
|
||||
if(BHLIB_USE_WINTHREAD)
|
||||
check_symbol_exists(_beginthread process.h BH_USE_WINTHREAD)
|
||||
if(BH_USE_WINTHREAD)
|
||||
message(STATUS "Multithreading enabled")
|
||||
list(APPEND BHLIB_SOURCE
|
||||
list(APPEND BH_SOURCE
|
||||
src/thread_win.c
|
||||
)
|
||||
else()
|
||||
message(STATUS "Multithreading disabled")
|
||||
list(APPEND BHLIB_SOURCE
|
||||
list(APPEND BH_SOURCE
|
||||
src/thread_null.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if(BHLIB_NO_WINXP)
|
||||
if(BH_NO_WINXP)
|
||||
add_definitions(-D_WIN32_WINNT=_WIN32_WINNT_VISTA -DWINVER=_WIN32_WINNT_VISTA)
|
||||
endif()
|
||||
elseif(UNIX)
|
||||
message(STATUS "Platform: Unix (Linux/BSD/MacOS X)")
|
||||
set(BH_PLATFORM_POSIX TRUE)
|
||||
|
||||
# Add platform dependent files
|
||||
list(APPEND BH_SOURCE
|
||||
src/file_posix.c
|
||||
)
|
||||
|
||||
# Check multithreading support
|
||||
check_include_file(pthread.h BHLIB_USE_PTHREAD)
|
||||
if(BHLIB_USE_PTHREAD)
|
||||
check_include_file(pthread.h BH_USE_PTHREAD)
|
||||
if(BH_USE_PTHREAD)
|
||||
message(STATUS "Multithreading enabled")
|
||||
list(APPEND BHLIB_SOURCE
|
||||
list(APPEND BH_SOURCE
|
||||
src/thread_posix.c
|
||||
)
|
||||
else()
|
||||
message(STATUS "Multithreading disabled")
|
||||
list(APPEND BHLIB_SOURCE
|
||||
list(APPEND BH_SOURCE
|
||||
src/thread_null.c
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Platform: Unknown")
|
||||
message(STATUS "Multithreading disabled")
|
||||
list(APPEND BHLIB_SOURCE
|
||||
list(APPEND BH_SOURCE
|
||||
src/thread_null.c
|
||||
src/file_null.c
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -98,8 +113,8 @@ endif()
|
||||
configure_file(include/bh/config.in include/bh/config.h)
|
||||
|
||||
# Library
|
||||
add_library(bhlib STATIC ${BHLIB_SOURCE} ${BHLIB_HEADER})
|
||||
target_include_directories(bhlib PUBLIC ${BHLIB_INCLUDE_DIRS})
|
||||
add_library(bhlib STATIC ${BH_SOURCE} ${BH_HEADER})
|
||||
target_include_directories(bhlib PUBLIC ${BH_INCLUDE_DIRS})
|
||||
|
||||
# Runtime definition
|
||||
add_executable(main
|
||||
|
||||
Reference in New Issue
Block a user