Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
11 changes: 11 additions & 0 deletions 0xtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

file(GLOB TEST_SOURCES
unit/*.c
rand.c
main.c
)

add_executable(0xtest ${TEST_SOURCES})
target_include_directories(0xtest PUBLIC .)
target_compile_definitions(0xtest PRIVATE TARGET_0XTEST)
target_link_libraries(0xtest PUBLIC 0xc)
104 changes: 104 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
cmake_minimum_required(VERSION 4.0)
set(CMAKE_C_STANDARD 11)
Comment thread
FoxMoss marked this conversation as resolved.

project(lib0xc C)

# only export debug symbols if someone is working on the project
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()

file(GLOB LIB_SOURCES
src/0xc/*.c
src/0xc/std/*.c
src/0xc/std/call/field/type/*.c
src/0xc/std/call/field/*.c
src/0xc/sys/*.c
src/0xc/sys/buff/*.c
src/0xc/sys/buff/type/*.c
src/0xc/sys/check/*.c
src/0xc/sys/log/*.c
posix/0xc/posix/std/alloc.c
posix/0xc/posix/sys/buff/type/mmap.c
posix/0xc/posix/sys/log/stream.c
posix/0xc/posix/sys/panic.c
)

file(GLOB LIB_HEADERS
src/0xc/shim/*.h
src/0xc/std/*.h
src/0xc/sys/*.h
src/0xc/sys/buff/*.h
)

Comment thread
FoxMoss marked this conversation as resolved.
add_library(0xc
${LIB_SOURCES}
)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(0xc PRIVATE -g)
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_options(0xc PRIVATE -O3)
target_link_options(0xc PRIVATE -O3)
endif()

target_compile_options(0xc PUBLIC
Comment thread
FoxMoss marked this conversation as resolved.
-Werror
Comment thread
FoxMoss marked this conversation as resolved.
-Wall
-Wextra
-Wcast-qual
-Wconversion
-Wformat=2
-Wformat-security
-Wnull-dereference
-Wvla
-Warray-bounds
-Wimplicit-fallthrough
-Wint-conversion
-Wdouble-promotion
-Wstrict-prototypes
-Wbad-function-cast
-Wfloat-equal
-Wpointer-arith
-Wundef
)

if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(0xc PUBLIC
-Wshorten-64-to-32
-Warray-bounds-pointer-arithmetic
-Wconditional-uninitialized
-Wloop-analysis
-Wshift-sign-overflow
-Wtautological-constant-in-range-compare
-Wcomma
-Wassign-enum
-Wformat-type-confusion
-Widiomatic-parentheses
-Wunreachable-code-aggressive
-Wthread-safety
-ftrivial-auto-var-init=zero
-Wno-duplicate-decl-specifier
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(0xc PUBLIC
-Wformat-signedness
-Wuninitialized
-Wlogical-op
-Wduplicated-cond
)
endif()

target_include_directories(0xc PUBLIC src posix)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_definitions(0xc PRIVATE POINTER_TAG_BITS_HI=16 POINTER_TAG_BITS_LO=3)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_compile_definitions(0xc PRIVATE POINTER_TAG_BITS_HI=0 POINTER_TAG_BITS_LO=3)
endif()

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_subdirectory(0xtest)
endif()