diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b86268..94f61ce 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;${{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: @@ -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 @@ -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: @@ -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 @@ -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: 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