Skip to content
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

20 implement cmake install rules #22

Merged
merged 3 commits into from
Aug 30, 2024
Merged
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
21 changes: 21 additions & 0 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,25 @@ jobs:
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}

install:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Initialize Git Submodules
run: |
git submodule update --init

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=OFF

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Install
run: sudo cmake --install ${{github.workspace}}/build
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.22)
project(myxml
VERSION 0.1)

enable_testing()

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
Expand All @@ -16,7 +15,21 @@ endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED on)

add_subdirectory(deps/fmt)
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(deps/Catch2)
add_subdirectory(deps/fmt)

install(TARGETS myxml
EXPORT myxml
ARCHIVE DESTINATION lib)

install(DIRECTORY include/
DESTINATION include)

option(BUILD_TESTING "Build the testing tree." ON)

if (BUILD_TESTING)
enable_testing()

add_subdirectory(deps/Catch2)
add_subdirectory(tests)
endif()
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ Contributions are welcome! Read [Contribution Guide](./docs/contribution_guide.m
- Integrate DTD/XML Schema Validation
- Refactor for Zero-Copy Efficiency

## Build
## Setup

The `cmake install` command is not yes implemented. You can include the repo as a sub directory of your project and use `add_subdirectory()` to use the `myxml` target.
### Dependencies

### Dependency

To fetch Catch2 testing framework, run:
**myxml** uses git submodule to manage dependencies. Run following commands first:

```bash
git submodule init
Expand All @@ -46,17 +44,29 @@ cmake -S . -B build
cmake --build build
```

If you don't want to compile testing, add `-DBUILD_TESING=OFF` to the configure command.

### Running tests

Ensure Catch2 is installed correctly. In the project directory, run:
In the project directory, run:

```bash
ctest --test-dir build/tests/
```

### Installation

In the project directory, run:

```bash
cmake --install build # usually requires root permission
```

Then your C++ Compiler will be able to find **myxml** directly.

### Integration

To integrate myxml, add this repo to your project and modify your root `CMakeLists.txt`:
If you want to integrate **myxml** into your CMake project, add this repo to your project and modify your root `CMakeLists.txt`:

```cmake
add_subdirectory(myxml) # or `deps/myxml`, as you like
Expand Down