From 58c3392bb6222e9708ad7174ee232d8ef8e9b8b1 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 8 Aug 2023 15:55:13 +0200 Subject: [PATCH] Test example downstream project Only on Linux yet --- .github/workflows/build.yml | 16 ++++++++++++++++ CMakeLists.txt | 2 +- example/CMakeLists.txt | 19 +++++++++++++++++++ example/main.cpp | 10 ++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 example/CMakeLists.txt create mode 100644 example/main.cpp diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b86268..597be57 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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: diff --git a/CMakeLists.txt b/CMakeLists.txt index d3a2b88..e34eb22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}::") diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..5cc51c6 --- /dev/null +++ b/example/CMakeLists.txt @@ -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) + diff --git a/example/main.cpp b/example/main.cpp new file mode 100644 index 0000000..f973c73 --- /dev/null +++ b/example/main.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main() +{ + FILE dst_file, src_file; + bgcode::convert::from_binary_to_ascii(src_file, dst_file, true); + + return 0; +} \ No newline at end of file