diff --git a/.github/scripts/build-c-api-bindings.sh b/.github/scripts/build-c-api-bindings.sh index 6967b6de..fdc2f1f8 100755 --- a/.github/scripts/build-c-api-bindings.sh +++ b/.github/scripts/build-c-api-bindings.sh @@ -40,10 +40,11 @@ echo "compiler: $(${CXX:-c++} --version | head -1)" rm -rf "${BUILD_DIR}" "${INSTALL_DIR}" -cmake -B"${BUILD_DIR}" -S"${WORKSPACE}/bindings/c" \ +cmake -B"${BUILD_DIR}" -S"${WORKSPACE}" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ -DCMAKE_INSTALL_LIBDIR=lib \ + -DSVS_BUILD_C_API=ON \ -DSVS_BUILD_C_API_TESTS=ON \ -DSVS_BUILD_EXAMPLES=ON \ -DSVS_RUNTIME_ENABLE_LVQ_LEANVEC="${ENABLE_LVQ_LEANVEC}" \ diff --git a/.github/scripts/test-c-api-unit.sh b/.github/scripts/test-c-api-unit.sh index 7ea6e322..a787e526 100755 --- a/.github/scripts/test-c-api-unit.sh +++ b/.github/scripts/test-c-api-unit.sh @@ -42,6 +42,6 @@ ctest --test-dir "${BUILD_DIR}" --output-on-failure --no-tests=error # exit once already, so they are part of the gate. for sample in c_api_simple c_api_save_load c_api_dynamic; do echo "::group::${sample}" - "${BUILD_DIR}/samples/${sample}" + "${BUILD_DIR}/examples/c/${sample}" echo "::endgroup::" done diff --git a/CMakeLists.txt b/CMakeLists.txt index 62377bef..d71f6dd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,11 +94,22 @@ endif() ##### Build Objects ##### +if(SVS_BUILD_C_API) + add_subdirectory(bindings/c) + if(SVS_BUILD_C_API_TESTS) + include(CTest) + enable_testing() + endif() +endif() + if(SVS_BUILD_BINARIES) add_subdirectory(utils) endif() if(SVS_BUILD_TESTS) + # Add test to CTest + include(CTest) + enable_testing() add_subdirectory(tests) endif() diff --git a/bindings/c/CMakeLists.txt b/bindings/c/CMakeLists.txt index 9ed1247b..5d9a7c45 100644 --- a/bindings/c/CMakeLists.txt +++ b/bindings/c/CMakeLists.txt @@ -270,7 +270,3 @@ if(SVS_BUILD_C_API_TESTS) endif() add_subdirectory(tests) endif() - -if(SVS_BUILD_EXAMPLES) - add_subdirectory(samples) -endif() diff --git a/cmake/options.cmake b/cmake/options.cmake index b02b6785..ff429373 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -31,6 +31,11 @@ option(SVS_BUILD_BINARIES OFF # enabled by default ) +option(SVS_BUILD_C_API + "Build C API bindings" + OFF # disabled by default +) + option(SVS_BUILD_TESTS "Build the unit test suite." OFF # disabled by default diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index eaabf8f1..c16d7cd6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -13,3 +13,7 @@ # limitations under the License. add_subdirectory(cpp) + +if(SVS_BUILD_C_API) + add_subdirectory(c) +endif() diff --git a/bindings/c/samples/CMakeLists.txt b/examples/c/CMakeLists.txt similarity index 95% rename from bindings/c/samples/CMakeLists.txt rename to examples/c/CMakeLists.txt index c23b1a02..a92ef392 100644 --- a/bindings/c/samples/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +project(svs_c_api_samples LANGUAGES C) foreach(SAMPLE_NAME simple save_load dynamic) set(SAMPLE_TARGET c_api_${SAMPLE_NAME}) list(APPEND SAMPLE_TARGETS ${SAMPLE_TARGET}) diff --git a/bindings/c/samples/dynamic.c b/examples/c/dynamic.c similarity index 100% rename from bindings/c/samples/dynamic.c rename to examples/c/dynamic.c diff --git a/bindings/c/samples/save_load.c b/examples/c/save_load.c similarity index 100% rename from bindings/c/samples/save_load.c rename to examples/c/save_load.c diff --git a/bindings/c/samples/simple.c b/examples/c/simple.c similarity index 100% rename from bindings/c/samples/simple.c rename to examples/c/simple.c