MYNT-EYE-S-SDK/CMakeLists.txt

394 lines
12 KiB
CMake
Raw Normal View History

2018-05-10 09:46:34 +03:00
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
2018-03-11 18:15:30 +02:00
cmake_minimum_required(VERSION 3.0)
2019-03-07 02:51:27 +02:00
project(mynteye VERSION 2.3.3 LANGUAGES C CXX)
2018-03-11 18:15:30 +02:00
2018-04-23 18:11:11 +03:00
include(cmake/Common.cmake)
2018-11-01 14:42:44 +02:00
if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX d)
endif()
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
2018-09-04 11:07:36 +03:00
find_package(Threads QUIET)
macro(target_link_threads NAME)
if(THREADS_HAVE_PTHREAD_ARG)
target_compile_options(PUBLIC ${NAME} "-pthread")
endif()
if(CMAKE_THREAD_LIBS_INIT)
2019-01-14 16:27:38 +02:00
target_link_libraries(${NAME} PUBLIC "${CMAKE_THREAD_LIBS_INIT}")
2018-09-04 11:07:36 +03:00
endif()
endmacro()
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
2018-05-07 11:29:20 +03:00
set(MYNTEYE_NAME ${PROJECT_NAME})
2018-03-11 18:15:30 +02:00
set(MYNTEYE_NAMESPACE "mynteye")
message(STATUS "Namespace: ${MYNTEYE_NAMESPACE}")
if(MSVC)
string(REPLACE "/" "\\\\" MYNTEYE_SDK_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
string(REPLACE "/" "\\\\" MYNTEYE_SDK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
else()
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" MYNTEYE_SDK_ROOT_DIR)
file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}" MYNTEYE_SDK_INSTALL_DIR)
endif()
2018-06-04 17:09:20 +03:00
2018-03-11 18:15:30 +02:00
configure_file(
include/mynteye/mynteye.h.in
include/mynteye/mynteye.h @ONLY
)
2018-11-01 17:34:52 +02:00
configure_file(
cmake/templates/pkginfo.sh.in
${CMAKE_CURRENT_SOURCE_DIR}/pkginfo.sh @ONLY
)
2018-11-01 17:12:36 +02:00
if(OS_WIN)
configure_file(
scripts/win/nsis/winpack.nsi.in
${CMAKE_CURRENT_SOURCE_DIR}/winpack.nsi @ONLY
)
endif()
2019-01-09 08:30:21 +02:00
# rpath
set(CMAKE_MACOSX_RPATH 1)
set(MYNTEYE_CMAKE_RPATH "")
if(WITH_OPENCV)
list(APPEND MYNTEYE_CMAKE_RPATH ${OpenCV_LIB_PATH})
endif()
if(MYNTEYE_CMAKE_RPATH)
message(STATUS "RPATH: ${MYNTEYE_CMAKE_RPATH}")
set(CMAKE_INSTALL_RPATH "${MYNTEYE_CMAKE_RPATH}")
endif()
2018-03-11 18:15:30 +02:00
# 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
## main
2018-09-04 09:35:27 +03:00
if(WITH_GLOG)
add_executable(main src/main.cc)
target_link_libraries(main glog::glog)
target_include_directories(main PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
)
endif()
2018-03-22 06:57:35 +02:00
## camodocal
if(WITH_CAM_MODELS)
2019-01-28 04:16:29 +02:00
set(EIGEN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
2019-01-28 04:08:41 +02:00
message(STATUS "EIGEN_INCLUDE_DIR: ${EIGEN_INCLUDE_DIR}")
include_directories(
2019-01-28 04:08:41 +02:00
${EIGEN_INCLUDE_DIR}
src/mynteye/api/camodocal/include
)
add_library(camodocal STATIC
src/mynteye/api/camodocal/src/camera_models/Camera.cc
src/mynteye/api/camodocal/src/camera_models/EquidistantCamera.cc
src/mynteye/api/camodocal/src/gpl/gpl.cc
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
2018-03-22 06:57:35 +02:00
## libmynteye
2018-09-11 05:10:14 +03:00
if(NOT WITH_GLOG AND NOT OS_WIN)
2018-09-04 12:00:18 +03:00
set(__MINIGLOG_FLAGS "-Wno-unused-parameter -Wno-format -Wno-return-type")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${__MINIGLOG_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${__MINIGLOG_FLAGS}")
unset(__MINIGLOG_FLAGS)
endif()
2018-11-16 10:30:13 +02:00
if(NOT WITH_GLOG)
list(APPEND MYNTEYE_PUBLIC_H
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/miniglog.h
)
endif()
2018-09-04 12:00:18 +03:00
2018-03-22 06:57:35 +02:00
if(OS_WIN)
set(UVC_SRC src/mynteye/uvc/win/uvc-wmf.cc)
2018-03-22 06:57:35 +02:00
elseif(OS_MAC)
2018-12-19 07:30:25 +02:00
add_compile_options(-x objective-c++ -Wno-unused-command-line-argument -Wno-missing-method-return-type -Wno-sign-compare)
2018-12-11 11:08:31 +02:00
INCLUDE_DIRECTORIES(src/mynteye/uvc/macosx/USBBusProber.framework/Headers)
INCLUDE_DIRECTORIES(src/mynteye/uvc/macosx/VVUVCKit.framework/Headers)
find_library(VVUVCKIT_LIBRARY VVUVCKit PATHS src/mynteye/uvc/macosx)
find_library(USB_LIBRARY USBBusProber PATHS src/mynteye/uvc/macosx)
MARK_AS_ADVANCED (VVUVCKIT_LIBRARY USB_LIBRARY)
SET(OSX_EXTRA_LIBS ${VVUVCKIT_LIBRARY} ${USB_LIBRARY})
set(UVC_SRC src/mynteye/uvc/macosx/CameraEngine.cpp src/mynteye/uvc/macosx/AVfoundationCamera.mm src/mynteye/uvc/macosx/uvc-vvuvckit.cc )
2018-12-31 00:45:25 +02:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework CoreFoundation -framework AVFoundation -framework IOKit -framework AppKit -framework Cocoa -framework CoreMedia -framework CoreData -framework Foundation -framework CoreVideo ${__MACUVCLOG_FLAGS}")
2018-03-22 06:57:35 +02:00
elseif(OS_LINUX)
set(UVC_SRC src/mynteye/uvc/linux/uvc-v4l2.cc)
2018-03-22 06:57:35 +02:00
else()
message(FATAL_ERROR "Unsupported OS.")
endif()
set(MYNTEYE_SRCS
${UVC_SRC}
2018-10-27 16:24:04 +03:00
src/mynteye/types.cc
src/mynteye/util/files.cc
src/mynteye/util/strings.cc
src/mynteye/device/channel/bytes.cc
src/mynteye/device/channel/channels.cc
src/mynteye/device/channel/file_channel.cc
2018-10-27 16:24:04 +03:00
src/mynteye/device/config.cc
src/mynteye/device/context.cc
src/mynteye/device/device.cc
src/mynteye/device/motions.cc
src/mynteye/device/standard/channels_adapter_s.cc
src/mynteye/device/standard/device_s.cc
src/mynteye/device/standard/streams_adapter_s.cc
src/mynteye/device/standard2/channels_adapter_s2.cc
src/mynteye/device/standard2/device_s2.cc
src/mynteye/device/standard2/streams_adapter_s2.cc
2018-10-27 16:24:04 +03:00
src/mynteye/device/streams.cc
src/mynteye/device/types.cc
src/mynteye/device/utils.cc
2018-03-22 06:57:35 +02:00
)
2018-04-25 11:06:38 +03:00
if(WITH_API)
list(APPEND MYNTEYE_SRCS
2018-10-27 16:24:04 +03:00
src/mynteye/api/api.cc
src/mynteye/api/dl.cc
src/mynteye/api/processor.cc
src/mynteye/api/synthetic.cc
src/mynteye/api/processor/disparity_processor.cc
src/mynteye/api/processor/disparity_normalized_processor.cc
src/mynteye/api/processor/root_camera_processor.cc
src/mynteye/api/processor/points_processor_ocv.cc
src/mynteye/api/processor/depth_processor_ocv.cc
src/mynteye/api/processor/rectify_processor_ocv.cc
src/mynteye/api/config.cc
src/mynteye/api/correspondence.cc
2019-02-27 02:14:37 +02:00
src/mynteye/api/version_checker.cc
src/mynteye/api/data_tools.cc
)
if(WITH_CAM_MODELS)
list(APPEND MYNTEYE_SRCS
src/mynteye/api/processor/depth_processor.cc
src/mynteye/api/processor/points_processor.cc
src/mynteye/api/processor/rectify_processor.cc
)
endif()
endif()
if(NOT WITH_GLOG)
2018-10-27 16:24:04 +03:00
list(APPEND MYNTEYE_SRCS src/mynteye/miniglog.cc)
2018-09-04 12:00:18 +03:00
endif()
2018-03-22 06:57:35 +02:00
2018-09-04 09:35:27 +03:00
set(MYNTEYE_LINKLIBS ${UVC_LIB})
2018-04-26 04:22:29 +03:00
if(WITH_API)
list(APPEND MYNTEYE_LINKLIBS ${OpenCV_LIBS})
endif()
2018-06-04 17:09:20 +03:00
if(WITH_BOOST_FILESYSTEM)
list(APPEND MYNTEYE_LINKLIBS ${Boost_LIBRARIES})
endif()
2018-09-04 09:35:27 +03:00
if(WITH_GLOG)
list(APPEND MYNTEYE_LINKLIBS glog::glog)
endif()
2018-03-22 06:57:35 +02:00
#message(STATUS "MYNTEYE_LINKLIBS: ${MYNTEYE_LINKLIBS}")
add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS})
2019-01-14 16:27:38 +02:00
target_link_libraries(${MYNTEYE_NAME} PUBLIC ${MYNTEYE_LINKLIBS})
2018-12-11 11:08:31 +02:00
if(OS_MAC)
2019-01-14 16:27:38 +02:00
target_link_libraries(${MYNTEYE_NAME} PUBLIC ${OSX_EXTRA_LIBS} )
2018-12-11 11:08:31 +02:00
endif()
if(WITH_CAM_MODELS)
2019-01-14 16:27:38 +02:00
target_link_libraries(${MYNTEYE_NAME} PRIVATE camodocal)
endif()
2018-09-04 11:07:36 +03:00
target_link_threads(${MYNTEYE_NAME})
2018-03-22 06:57:35 +02:00
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>"
2018-10-27 16:24:04 +03:00
"$<INSTALL_INTERFACE:include>"
2018-03-22 06:57:35 +02:00
)
set_target_properties(${MYNTEYE_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
# install
2018-10-27 16:24:04 +03:00
set(MYNTEYE_CMAKE_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/${MYNTEYE_NAME}")
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}")
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/include/mynteye/mynteye.h
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/global.h
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/logger.h
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/types.h
DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}
)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/callbacks.h
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/context.h
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/device.h
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/types.h
2018-10-27 16:24:04 +03:00
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/utils.h
DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}/device
)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/util/files.h
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/util/strings.h
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/util/times.h
DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}/util
)
if(WITH_API)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/api/api.h
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/api/plugin.h
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/api/object.h
DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}/api
)
endif()
if(NOT WITH_GLOG)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/miniglog.h
DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}
)
endif()
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/callbacks.h
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/context.h
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/device.h
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/files.h
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/glog_init.h
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/strings.h
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/times.h
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/utils.h
DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}
)
if(WITH_API)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/api.h
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/plugin.h
${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/object.h
DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}
)
endif()
2018-03-22 06:57:35 +02:00
2019-01-14 16:27:38 +02:00
install(TARGETS ${MYNTEYE_NAME}
2018-03-22 06:57:35 +02:00
EXPORT ${MYNTEYE_NAME}-targets
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}
)
2018-06-04 08:47:06 +03:00
## build.info
2018-06-04 08:47:06 +03:00
2018-07-11 07:59:56 +03:00
# set default int values for yaml file (build.info)
set_default_value(CMAKE_CXX_COMPILER_VERSION_MAJOR 0)
set_default_value(CMAKE_CXX_COMPILER_VERSION_MINOR 0)
set_default_value(CMAKE_CXX_COMPILER_VERSION_PATCH 0)
set_default_value(CMAKE_CXX_COMPILER_VERSION_TWEAK 0)
set_default_value(CUDA_VERSION_MAJOR 0)
set_default_value(CUDA_VERSION_MINOR 0)
set_default_value(OpenCV_VERSION_MAJOR 0)
set_default_value(OpenCV_VERSION_MINOR 0)
set_default_value(OpenCV_VERSION_PATCH 0)
set_default_value(OpenCV_VERSION_TWEAK 0)
set_default_value(${PROJECT_NAME}_VERSION_MAJOR 0)
set_default_value(${PROJECT_NAME}_VERSION_MINOR 0)
set_default_value(${PROJECT_NAME}_VERSION_PATCH 0)
set_default_value(${PROJECT_NAME}_VERSION_TWEAK 0)
2018-06-04 08:47:06 +03:00
configure_file(
cmake/templates/build.info.in
build.info @ONLY
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/build.info
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/mynteye
)