Skip to content

Commit

Permalink
Merge branch 'tm_add_cmd_tool' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasmeszaros committed Aug 8, 2023
2 parents d954278 + deac930 commit 2a56dac
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
cmake -E make_directory ${{github.workspace}}/build
cmake -E make_directory ${{github.workspace}}/build/dist
cmake -E make_directory ${{github.workspace}}/deps/build
cmake -E make_directory ${{github.workspace}}/example/build_fp
cmake -E make_directory ${{github.workspace}}/example/build_subd
- uses: actions/cache@v3
name: Getting dependency cache
Expand Down Expand Up @@ -67,6 +69,20 @@ jobs:
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest

- name: Build example (using find_package)
working-directory: ${{github.workspace}}/example/build_fp
shell: bash
run: |
cmake .. -DCMAKE_PREFIX_PATH="${{github.workspace}}/build/dist;${{github.workspace}}/deps/build/destdir/usr/local"
cmake --build .
- name: Build example (using add_subdirectory)
working-directory: ${{github.workspace}}/example/build_subd
shell: bash
run: |
cmake .. -DBGCODE_AS_SUBPROJECT=ON -DLibBGCode_BUILD_TESTS=OFF -DCMAKE_PREFIX_PATH=${{github.workspace}}/deps/build/destdir/usr/local
cmake --build .
- uses: actions/upload-artifact@v3 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
Expand Down Expand Up @@ -100,6 +116,8 @@ jobs:
cmake -E make_directory ${{github.workspace}}\build
cmake -E make_directory ${{github.workspace}}\build\dist
cmake -E make_directory ${{github.workspace}}\deps\build
cmake -E make_directory ${{github.workspace}}\example\build_fp
cmake -E make_directory ${{github.workspace}}\example\build_subd
- uses: actions/cache@v3
name: Getting dependency cache
Expand Down Expand Up @@ -137,6 +155,18 @@ jobs:
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest

- name: Build example (using find_package)
working-directory: ${{github.workspace}}\example\build_fp
run: |
cmake .. -DCMAKE_PREFIX_PATH="${{github.workspace}}\build\dist;${{github.workspace}}\deps\build\destdir\usr\local"
cmake --build . --config Release
- name: Build example (using add_subdirectory)
working-directory: ${{github.workspace}}\example\build_subd
run: |
cmake .. -DBGCODE_AS_SUBPROJECT=ON -DLibBGCode_BUILD_TESTS=OFF -DCMAKE_PREFIX_PATH=${{github.workspace}}\deps\build\destdir\usr\local
cmake --build . --config Release
- uses: actions/upload-artifact@v3 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
Expand Down Expand Up @@ -164,6 +194,8 @@ jobs:
cmake -E make_directory ${{github.workspace}}/build
cmake -E make_directory ${{github.workspace}}/build/dist
cmake -E make_directory ${{github.workspace}}/deps/build
cmake -E make_directory ${{github.workspace}}/example/build_fp
cmake -E make_directory ${{github.workspace}}/example/build_subd
- uses: actions/cache@v3
name: Getting dependency cache
Expand Down Expand Up @@ -203,6 +235,20 @@ jobs:
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest

- name: Build example (using find_package)
working-directory: ${{github.workspace}}/example/build_fp
shell: bash
run: |
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DCMAKE_PREFIX_PATH="${{github.workspace}}/build/dist;${{github.workspace}}/deps/build/destdir/usr/local"
cmake --build .
- name: Build example (using add_subdirectory)
working-directory: ${{github.workspace}}/example/build_subd
shell: bash
run: |
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DBGCODE_AS_SUBPROJECT=ON -DLibBGCode_BUILD_TESTS=OFF -DCMAKE_PREFIX_PATH=${{github.workspace}}/deps/build/destdir/usr/local
cmake --build .
- uses: actions/upload-artifact@v3 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ endif()

# Set this if downstream would need to link additional boost
# components
set(Boost_DOWNSTREAM_COMPONENTS nowide)
set(Boost_DOWNSTREAM_COMPONENTS "")

set(namespace "${PROJECT_NAME}::")

Expand Down
19 changes: 19 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.12)
project(bgcode_client)

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option (BGCODE_AS_SUBPROJECT "Import bgcode library with add_subdirectory, instead of find_package" OFF)

if (BGCODE_AS_SUBPROJECT)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/upstream)
else ()
find_package(LibBGCode REQUIRED)
endif ()

add_executable(${PROJECT_NAME} main.cpp)

target_link_libraries(${PROJECT_NAME} LibBGCode::bgcode_convert)

10 changes: 10 additions & 0 deletions example/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <cstdio>
#include <LibBGCode/convert/convert.hpp>

int main()
{
FILE dst_file, src_file;
bgcode::convert::from_binary_to_ascii(src_file, dst_file, true);

return 0;
}

0 comments on commit 2a56dac

Please sign in to comment.