-
Notifications
You must be signed in to change notification settings - Fork 22
feat: cmake support #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FoxMoss
wants to merge
6
commits into
microsoft:public
Choose a base branch
from
FoxMoss:cmake-support
base: public
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
600f268
feat: cmake support
FoxMoss 4e7d793
fix: add clang & gcc specific flags
FoxMoss 24dce58
fix: add release and debug flags
FoxMoss 238229c
chore: clean up cmake
FoxMoss 9207381
Merge remote-tracking branch 'origin/public' into cmake-support
FoxMoss 8b907c6
chore: add -Wundef to cmake
FoxMoss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
|
|
||
| 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 | ||
| ) | ||
|
|
||
|
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 | ||
|
FoxMoss marked this conversation as resolved.
|
||
| -Werror | ||
|
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() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.