-
Notifications
You must be signed in to change notification settings - Fork 2
Add cmake #13
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
Merged
Merged
Add cmake #13
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
170144a
add kmtest submodule
ElwooD07 63001e4
add cmake build configuration
ElwooD07 ad3f8e3
make kf as static library
ElwooD07 613439c
fix build with STL features
ElwooD07 4c10758
implement tests for Hex, fix compilation and linkage
ElwooD07 935a393
fix _Xout_of_range logic
belyshevdenis 5956d53
fix misspelling in Hex.h
belyshevdenis b1f8f69
fix parameters check in kf::Hex::decode
ElwooD07 31c0ec0
Merge branch 'add-cmake' of https://github.com/apriorit/kf into add-c…
ElwooD07 2f95ae7
make kf project as header-only target
69a8388
replace gitmodules with FetchContent
4003078
remove debug message
7af9d5e
split generation of standalone project by CMake from simple inclusion…
belyshevdenis d97ce2c
update README.md and add it to the project root
belyshevdenis 6825e96
returned root files to kf headers root view
belyshevdenis be847d4
set warning level to 3
belyshevdenis 13a9fb1
Update cmake projects
SergiusTheBest 777e387
Revert changes not related to CMake, update README
SergiusTheBest 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,49 @@ | ||
| cmake_minimum_required(VERSION 3.16) | ||
|
|
||
| project(kf LANGUAGES CXX) | ||
|
|
||
| # Check if building as a stand-alone project | ||
| if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) | ||
| set(IS_TOPLEVEL_PROJECT TRUE) | ||
| else() | ||
| set(IS_TOPLEVEL_PROJECT FALSE) | ||
| endif() | ||
|
|
||
| add_library(${PROJECT_NAME} INTERFACE) | ||
| add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) | ||
|
|
||
| target_include_directories(${PROJECT_NAME} | ||
| INTERFACE | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
| ) | ||
|
|
||
| if(${IS_TOPLEVEL_PROJECT}) | ||
| set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
|
|
||
| # Add a pseudo-project to make kf headers visible in IDE | ||
| file(GLOB_RECURSE ${PROJECT_NAME}_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/kf/*") | ||
|
|
||
| # Organize files into filters matching their relative paths | ||
| foreach(header ${${PROJECT_NAME}_HEADERS}) | ||
| file(RELATIVE_PATH rel_path "${CMAKE_CURRENT_SOURCE_DIR}" "${header}") | ||
|
|
||
| get_filename_component(rel_dir "${rel_path}" DIRECTORY) | ||
| if(rel_dir) | ||
| string(REPLACE "/" "\\" filter "${rel_dir}") | ||
| source_group("${filter}" FILES "${header}") | ||
| endif() | ||
| endforeach() | ||
|
|
||
| add_custom_target(${PROJECT_NAME}-headers SOURCES ${${PROJECT_NAME}_HEADERS}) | ||
| set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) | ||
|
|
||
| # Add all .md files from the root directory to the solution | ||
| file(GLOB ROOT_MD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.md") | ||
| add_custom_target("docs" SOURCES ${ROOT_MD_FILES}) | ||
|
|
||
| # Add tests | ||
| add_subdirectory("test") | ||
| endif() | ||
|
|
||
| # TODO: add install target |
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
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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| #pragma once | ||
| #include "USimpleString.h" | ||
| #include "ASimpleString.h" | ||
| #include <span> | ||
| #include <array> | ||
|
|
||
|
|
||
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,48 @@ | ||
| cmake_minimum_required(VERSION 3.16) | ||
|
|
||
| project(kf-test LANGUAGES CXX) | ||
|
|
||
| # Set C++ standard | ||
| set(CMAKE_CXX_STANDARD 20) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
|
||
| # Set warning level to /W4 for MSVC | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX") | ||
|
|
||
| # TODO: fix warnings in code and remove this define | ||
| add_compile_definitions(_CRT_SECURE_NO_WARNINGS=1) | ||
|
|
||
| # Fetch dependencies | ||
| include(FetchContent) | ||
|
|
||
| # TODO: add stable reference in future | ||
| FetchContent_Declare( | ||
| findwdk | ||
| GIT_REPOSITORY https://github.com/SergiusTheBest/FindWDK | ||
| GIT_TAG stl | ||
| ) | ||
|
|
||
| # TODO: add stable reference in future | ||
| FetchContent_Declare( | ||
| kmtest | ||
| GIT_REPOSITORY https://github.com/SergiusTheBest/kmtest.git | ||
| ) | ||
|
|
||
| FetchContent_MakeAvailable(findwdk kmtest) | ||
|
|
||
| # Add CMake package for WDK projects | ||
| list(APPEND CMAKE_MODULE_PATH "${findwdk_SOURCE_DIR}/cmake") | ||
| find_package(WDK REQUIRED) | ||
|
|
||
| wdk_add_driver(kf-test WINVER NTDDI_WIN10 STL | ||
| pch.h | ||
| pch.cpp | ||
| HexTest.cpp | ||
| ) | ||
|
|
||
| target_link_libraries(kf-test kf::kf kmtest::kmtest) | ||
|
|
||
| # Activate precompiled headers, unfortunately `target_precompile_headers` doesn't work with `wdk_add_driver` | ||
| set_target_properties(kf-test PROPERTIES COMPILE_FLAGS "/Yupch.h") | ||
| set_source_files_properties(pch.cpp PROPERTIES COMPILE_FLAGS "/Ycpch.h") |
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,7 @@ | ||
| #include "pch.h" | ||
| #include <kf/Hex.h> | ||
|
|
||
| SCENARIO("TODO: implement") | ||
| { | ||
| REQUIRE(true); | ||
| } |
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 @@ | ||
| #include "pch.h" |
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,42 @@ | ||
| #pragma once | ||
| #include <ntifs.h> | ||
| #include <array> | ||
| #include <kmtest/kmtest.h> | ||
|
|
||
| // TODO: move this default implementation to kf | ||
|
|
||
| /////////////////////////////////////////////////////////// | ||
| // Implement CRT error reporting and STL checks | ||
|
|
||
| extern "C" inline int _CrtDbgReport( | ||
| _In_ int /*_ReportType*/, | ||
| _In_opt_z_ char const* /*_FileName*/, | ||
| _In_ int /*_Linenumber*/, | ||
| _In_opt_z_ char const* /*_ModuleName*/, | ||
| _In_opt_z_ char const* /*_Format*/, | ||
| ...) | ||
| { | ||
| #pragma warning(suppress: 28159) // Consider using 'error logging or driver shutdown' instead of 'KeBugCheckEx' | ||
| KeBugCheckEx(KERNEL_SECURITY_CHECK_FAILURE, 0, 0, 0, 0); | ||
| } | ||
|
|
||
| namespace std | ||
| { | ||
| [[noreturn]] inline void __cdecl _Xinvalid_argument(_In_z_ const char* /*What*/) | ||
| { | ||
| #pragma warning(suppress: 28159) // Consider using 'error logging or driver shutdown' instead of 'KeBugCheckEx' | ||
| KeBugCheckEx(KERNEL_SECURITY_CHECK_FAILURE, 0, 0, 0, 0); | ||
| } | ||
|
|
||
| [[noreturn]] inline void __cdecl _Xlength_error(_In_z_ const char* /*What*/) | ||
| { | ||
| #pragma warning(suppress: 28159) // Consider using 'error logging or driver shutdown' instead of 'KeBugCheckEx' | ||
| KeBugCheckEx(KERNEL_SECURITY_CHECK_FAILURE, 0, 0, 0, 0); | ||
| } | ||
|
|
||
| [[noreturn]] inline void __cdecl _Xout_of_range(_In_z_ const char* /*What*/) | ||
| { | ||
| #pragma warning(suppress: 28159) // Consider using 'error logging or driver shutdown' instead of 'KeBugCheckEx' | ||
| KeBugCheckEx(KERNEL_SECURITY_CHECK_FAILURE, 0, 0, 0, 0); | ||
| } | ||
| } |
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.