Skip to content

Commit

Permalink
Test example downstream project
Browse files Browse the repository at this point in the history
Only on Linux yet
  • Loading branch information
tamasmeszaros committed Aug 8, 2023
1 parent d954278 commit 58c3392
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
16 changes: 16 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
cmake --build .
- name: Build example (using add_subdirectory)
working-directory: ${{github.workspace}}/example/build_subd
shell: bash
run: |
cmake .. -DBGCODE_AS_SUBPROJECT=ON
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 58c3392

Please sign in to comment.