MYNT-EYE-S-SDK/CMakeLists.txt

220 lines
5.6 KiB
CMake
Raw Normal View History

2018-03-11 18:15:30 +02:00
cmake_minimum_required(VERSION 3.0)
project(mynteye VERSION 2.0.0 LANGUAGES C CXX)
2018-04-23 18:11:11 +03:00
include(cmake/Common.cmake)
2018-03-11 18:15:30 +02:00
# options
2018-04-25 11:06:38 +03:00
include(cmake/Option.cmake)
2018-03-11 18:15:30 +02:00
# flags
2018-04-23 18:11:11 +03:00
if(OS_WIN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
endif()
2018-03-11 18:15:30 +02:00
include(cmake/DetectCXX11.cmake)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
string(STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
string(STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
message(STATUS "C_FLAGS: ${CMAKE_C_FLAGS}")
message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# packages
LIST(APPEND CMAKE_PREFIX_PATH third_party/glog/_build)
find_package(glog REQUIRED)
message(STATUS "Found glog: ${glog_VERSION}")
2018-04-26 04:22:29 +03:00
if(WITH_API)
find_package(OpenCV REQUIRED)
message(STATUS "Found OpenCV: ${OpenCV_VERSION}")
if(OpenCV_VERSION VERSION_LESS 3.0)
add_definitions(-DUSE_OPENCV2)
else()
add_definitions(-DUSE_OPENCV3)
endif()
endif()
2018-03-11 18:15:30 +02:00
LIST(APPEND CMAKE_MODULE_PATH cmake)
2018-03-22 06:57:35 +02:00
include(CMakePackageConfigHelpers)
2018-03-11 18:15:30 +02:00
# config
set(MYNTEYE_NAMESPACE "mynteye")
message(STATUS "Namespace: ${MYNTEYE_NAMESPACE}")
configure_file(
include/mynteye/mynteye.h.in
include/mynteye/mynteye.h @ONLY
)
# targets
2018-04-23 18:11:11 +03:00
add_definitions(-DMYNTEYE_EXPORTS)
2018-03-11 18:15:30 +02:00
2018-03-22 06:57:35 +02:00
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output")
2018-03-11 18:15:30 +02:00
set_outdir(
"${OUT_DIR}/lib"
"${OUT_DIR}/lib"
"${OUT_DIR}/bin"
)
2018-03-22 06:57:35 +02:00
set(MYNTEYE_CMAKE_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
set(MYNTEYE_CMAKE_BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
set(MYNTEYE_CMAKE_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
set(MYNTEYE_CMAKE_INSTALLDIR "${MYNTEYE_CMAKE_LIBDIR}/cmake/${MYNTEYE_NAME}")
## main
2018-03-11 18:15:30 +02:00
add_executable(main src/main.cc)
target_link_libraries(main glog::glog)
2018-03-22 06:57:35 +02:00
target_include_directories(main PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
)
## libmynteye
set(MYNTEYE_NAME ${PROJECT_NAME})
set(MYNTEYE_PUBLIC_H
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/callbacks.h
2018-03-22 06:57:35 +02:00
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/global.h
2018-04-09 04:28:58 +03:00
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/glog_init.h
2018-03-22 06:57:35 +02:00
${CMAKE_CURRENT_BINARY_DIR}/include/mynteye/mynteye.h
2018-04-03 05:27:28 +03:00
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/types.h
2018-04-20 07:44:23 +03:00
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/utils.h
${CMAKE_CURRENT_SOURCE_DIR}/src/device/context.h
${CMAKE_CURRENT_SOURCE_DIR}/src/device/device.h
${CMAKE_CURRENT_SOURCE_DIR}/src/internal/files.h
${CMAKE_CURRENT_SOURCE_DIR}/src/internal/strings.h
${CMAKE_CURRENT_SOURCE_DIR}/src/internal/times.h
2018-03-22 06:57:35 +02:00
)
2018-04-25 11:06:38 +03:00
if(WITH_API)
list(APPEND MYNTEYE_PUBLIC_H
${CMAKE_CURRENT_SOURCE_DIR}/src/api/api.h
)
endif()
2018-03-22 06:57:35 +02:00
if(OS_WIN)
set(UVC_SRC src/uvc/uvc-wmf.cc)
elseif(OS_MAC)
set(UVC_SRC src/uvc/uvc-libuvc.cc)
find_package(libuvc REQUIRED)
set(UVC_LIB ${libuvc_LIBRARIES})
include_directories(${libuvc_INCLUDE_DIRS})
elseif(OS_LINUX)
set(UVC_SRC src/uvc/uvc-v4l2.cc)
else()
message(FATAL_ERROR "Unsupported OS.")
endif()
set(MYNTEYE_SRCS
${UVC_SRC}
2018-04-09 10:54:14 +03:00
src/internal/channels.cc
2018-04-04 10:52:10 +03:00
src/internal/config.cc
2018-04-15 14:18:21 +03:00
src/internal/files.cc
2018-04-12 06:48:09 +03:00
src/internal/motions.cc
2018-04-08 07:23:33 +03:00
src/internal/streams.cc
2018-04-04 06:38:36 +03:00
src/internal/strings.cc
2018-04-03 16:01:36 +03:00
src/internal/types.cc
2018-04-03 05:27:28 +03:00
src/public/types.cc
2018-04-20 07:44:23 +03:00
src/public/utils.cc
2018-04-04 05:50:27 +03:00
src/device/context.cc
src/device/device.cc
2018-04-04 10:52:10 +03:00
src/device/device_s.cc
2018-03-22 06:57:35 +02:00
)
2018-04-25 11:06:38 +03:00
if(WITH_API)
list(APPEND MYNTEYE_SRCS
src/api/api.cc
2018-04-26 05:33:37 +03:00
src/api/synthetic.cc
2018-04-26 09:44:47 +03:00
src/api/processor/processor.cc
2018-04-27 04:58:53 +03:00
src/api/processor/rectify_processor.cc
src/api/processor/disparity_processor.cc
src/api/processor/disparity_normalized_processor.cc
src/api/processor/depth_processor.cc
src/api/processor/points_processor.cc
2018-04-25 11:06:38 +03:00
)
endif()
2018-03-22 06:57:35 +02:00
set(MYNTEYE_LINKLIBS
glog::glog
${UVC_LIB}
)
2018-04-26 04:22:29 +03:00
if(WITH_API)
list(APPEND MYNTEYE_LINKLIBS ${OpenCV_LIBS})
endif()
2018-03-22 06:57:35 +02:00
#message(STATUS "MYNTEYE_LINKLIBS: ${MYNTEYE_LINKLIBS}")
add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS})
target_link_libraries(${MYNTEYE_NAME} ${MYNTEYE_LINKLIBS})
if(OS_WIN)
target_compile_definitions(${MYNTEYE_NAME}
PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES
)
endif()
target_include_directories(${MYNTEYE_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:${MYNTEYE_CMAKE_INCLUDE_DIR}>"
)
set_target_properties(${MYNTEYE_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
set_target_properties(${MYNTEYE_NAME} PROPERTIES
PUBLIC_HEADER "${MYNTEYE_PUBLIC_H}"
)
# install
#message(STATUS "MYNTEYE_CMAKE_INCLUDE_DIR: ${MYNTEYE_CMAKE_INCLUDE_DIR}")
#message(STATUS "MYNTEYE_CMAKE_BINDIR: ${MYNTEYE_CMAKE_BINDIR}")
#message(STATUS "MYNTEYE_CMAKE_LIBDIR: ${MYNTEYE_CMAKE_LIBDIR}")
#message(STATUS "MYNTEYE_CMAKE_INSTALLDIR: ${MYNTEYE_CMAKE_INSTALLDIR}")
install(TARGETS ${MYNTEYE_NAME}
EXPORT ${MYNTEYE_NAME}-targets
PUBLIC_HEADER DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}/${MYNTEYE_NAME}
RUNTIME DESTINATION ${MYNTEYE_CMAKE_BINDIR}
LIBRARY DESTINATION ${MYNTEYE_CMAKE_LIBDIR}
ARCHIVE DESTINATION ${MYNTEYE_CMAKE_LIBDIR}
)
configure_package_config_file(mynteye-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/mynteye-config.cmake
INSTALL_DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(mynteye-config-version.cmake
VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/mynteye-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/mynteye-config-version.cmake
DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
)
install(EXPORT ${MYNTEYE_NAME}-targets
DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
)