Add with api option

This commit is contained in:
John Zhao 2018-04-25 16:06:38 +08:00
parent 2dc470e14f
commit cd28fa58d3
7 changed files with 91 additions and 0 deletions

View File

@ -6,6 +6,8 @@ include(cmake/Common.cmake)
# options # options
include(cmake/Option.cmake)
# flags # flags
if(OS_WIN) 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/strings.h
${CMAKE_CURRENT_SOURCE_DIR}/src/internal/times.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) if(OS_WIN)
set(UVC_SRC src/uvc/uvc-wmf.cc) set(UVC_SRC src/uvc/uvc-wmf.cc)
@ -119,6 +126,11 @@ set(MYNTEYE_SRCS
src/device/device.cc src/device/device.cc
src/device/device_s.cc src/device/device_s.cc
) )
if(WITH_API)
list(APPEND MYNTEYE_SRCS
src/api/api.cc
)
endif()
set(MYNTEYE_LINKLIBS set(MYNTEYE_LINKLIBS
glog::glog glog::glog

4
cmake/Option.cmake Normal file
View File

@ -0,0 +1,4 @@
option(WITH_API "Build with API layer, need OpenCV" ON)
message(STATUS "Options:")
message(STATUS " WITH_API: ${WITH_API}")

View File

@ -6,6 +6,10 @@ get_filename_component(PRO_DIR ${PROJECT_SOURCE_DIR} DIRECTORY)
include(${PRO_DIR}/cmake/Common.cmake) include(${PRO_DIR}/cmake/Common.cmake)
# options
include(${PRO_DIR}/cmake/Option.cmake)
# flags # flags
if(OS_WIN) if(OS_WIN)
@ -51,6 +55,12 @@ endif()
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output") set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output")
# samples above api layer
if(WITH_API)
add_subdirectory(api)
endif()
# samples above device layer # samples above device layer
add_subdirectory(device) add_subdirectory(device)

View File

@ -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()

11
samples/api/camera.cc Normal file
View File

@ -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;
}

15
src/api/api.cc Normal file
View File

@ -0,0 +1,15 @@
#include "api/api.h"
#include <glog/logging.h>
MYNTEYE_BEGIN_NAMESPACE
API::API() {
VLOG(2) << __func__;
}
API::~API() {
VLOG(2) << __func__;
}
MYNTEYE_END_NAMESPACE

17
src/api/api.h Normal file
View File

@ -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