diff --git a/CMakeLists.txt b/CMakeLists.txt index d0a6144..6c67ce0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ include(cmake/Common.cmake) # options +include(cmake/Option.cmake) + # flags if(OS_WIN) @@ -88,6 +90,11 @@ set(MYNTEYE_PUBLIC_H ${CMAKE_CURRENT_SOURCE_DIR}/src/internal/strings.h ${CMAKE_CURRENT_SOURCE_DIR}/src/internal/times.h ) +if(WITH_API) + list(APPEND MYNTEYE_PUBLIC_H + ${CMAKE_CURRENT_SOURCE_DIR}/src/api/api.h + ) +endif() if(OS_WIN) set(UVC_SRC src/uvc/uvc-wmf.cc) @@ -119,6 +126,11 @@ set(MYNTEYE_SRCS src/device/device.cc src/device/device_s.cc ) +if(WITH_API) + list(APPEND MYNTEYE_SRCS + src/api/api.cc + ) +endif() set(MYNTEYE_LINKLIBS glog::glog diff --git a/cmake/Option.cmake b/cmake/Option.cmake new file mode 100644 index 0000000..4d6a275 --- /dev/null +++ b/cmake/Option.cmake @@ -0,0 +1,4 @@ +option(WITH_API "Build with API layer, need OpenCV" ON) + +message(STATUS "Options:") +message(STATUS " WITH_API: ${WITH_API}") diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index ff1c88f..713faec 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -6,6 +6,10 @@ get_filename_component(PRO_DIR ${PROJECT_SOURCE_DIR} DIRECTORY) include(${PRO_DIR}/cmake/Common.cmake) +# options + +include(${PRO_DIR}/cmake/Option.cmake) + # flags if(OS_WIN) @@ -51,6 +55,12 @@ endif() set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output") +# samples above api layer + +if(WITH_API) + add_subdirectory(api) +endif() + # samples above device layer add_subdirectory(device) diff --git a/samples/api/CMakeLists.txt b/samples/api/CMakeLists.txt new file mode 100644 index 0000000..a578bb7 --- /dev/null +++ b/samples/api/CMakeLists.txt @@ -0,0 +1,22 @@ +get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) + +set_outdir( + "${OUT_DIR}/lib/${DIR_NAME}" + "${OUT_DIR}/lib/${DIR_NAME}" + "${OUT_DIR}/bin/${DIR_NAME}" +) + +## camera_a + +add_executable(camera_a camera.cc) +target_link_libraries(camera_a mynteye ${OpenCV_LIBS}) +target_create_scripts(camera_a DLL_SEARCH_PATHS + ${PRO_DIR}/_install/bin + ${OpenCV_LIB_SEARCH_PATH} +) + +if(OS_WIN) + target_compile_definitions(camera_a + PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES + ) +endif() diff --git a/samples/api/camera.cc b/samples/api/camera.cc new file mode 100644 index 0000000..d484623 --- /dev/null +++ b/samples/api/camera.cc @@ -0,0 +1,11 @@ +#include "mynteye/glog_init.h" + +#include "mynteye/api.h" + +MYNTEYE_USE_NAMESPACE + +int main(int argc, char *argv[]) { + glog_init _(argc, argv); + + return 0; +} diff --git a/src/api/api.cc b/src/api/api.cc new file mode 100644 index 0000000..043035e --- /dev/null +++ b/src/api/api.cc @@ -0,0 +1,15 @@ +#include "api/api.h" + +#include + +MYNTEYE_BEGIN_NAMESPACE + +API::API() { + VLOG(2) << __func__; +} + +API::~API() { + VLOG(2) << __func__; +} + +MYNTEYE_END_NAMESPACE diff --git a/src/api/api.h b/src/api/api.h new file mode 100644 index 0000000..12dc9fc --- /dev/null +++ b/src/api/api.h @@ -0,0 +1,17 @@ +#ifndef MYNTEYE_API_H_ // NOLINT +#define MYNTEYE_API_H_ +#pragma once + +#include "mynteye/mynteye.h" + +MYNTEYE_BEGIN_NAMESPACE + +class MYNTEYE_API API { + public: + API(); + ~API(); +}; + +MYNTEYE_END_NAMESPACE + +#endif // MYNTEYE_API_H_ NOLINT