Skip to content

Commit

Permalink
为 RMVLConfig 添加 COMPONENTS 选项,用于指定需要的模块
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoxi-scut committed Apr 12, 2024
1 parent 1cc8a31 commit d6a282d
Show file tree
Hide file tree
Showing 16 changed files with 282 additions and 157 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

# ----------------------------------------------------------------------------
# Build
# Include necessary CMake modules
# ----------------------------------------------------------------------------
# RMVL Install layout
include(cmake/RMVLInstall.cmake)
Expand Down
19 changes: 16 additions & 3 deletions cmake/FindHikSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif()

# add the include directories path
find_path(
HikSDK_INCLUDE_DIRS
HikSDK_INCLUDE_DIR
NAMES CameraParams.h MvCameraControl.h MvErrorDefine.h MvISPErrorDefine.h PixelType.h
PATHS "${mvcam_sdk_path}/include"
NO_DEFAULT_PATH
Expand All @@ -28,15 +28,28 @@ else()
endif()

find_library(
HikSDK_LIBS
HikSDK_LIB
NAMES "libMvCameraControl.so"
PATHS "${mvcam_sdk_path}/lib/${ARCH_HIKLIB}"
NO_DEFAULT_PATH
)

if(NOT TARGET hiksdk)
add_library(hiksdk SHARED IMPORTED)
set_target_properties(hiksdk PROPERTIES
IMPORTED_LOCATION "${HikSDK_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${HikSDK_INCLUDE_DIR}"
)
endif()

mark_as_advanced(HikSDK_LIB HikSDK_INCLUDE_DIR)

set(HikSDK_LIBS "hiksdk")
set(HikSDK_INCLUDE_DIRS "${HikSDK_INCLUDE_DIR}")

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
HikSDK
REQUIRED_VARS HikSDK_LIBS HikSDK_INCLUDE_DIRS
REQUIRED_VARS HikSDK_LIB HikSDK_INCLUDE_DIR
)
19 changes: 16 additions & 3 deletions cmake/FindMvSDK.cmake
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
# add the include directories path
find_path(
MvSDK_INCLUDE_DIRS
MvSDK_INCLUDE_DIR
NAMES CameraApi.h CameraDefine.h CameraStatus.h
PATHS "/usr/include"
NO_DEFAULT_PATH
)

# add libraries
find_library(
MvSDK_LIBS
MvSDK_LIB
PATHS "/lib"
NAMES "libMVSDK.so"
NO_DEFAULT_PATH
)

if(NOT TARGET mvsdk)
add_library(mvsdk SHARED IMPORTED)
set_target_properties(mvsdk PROPERTIES
IMPORTED_LOCATION "${MvSDK_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${MvSDK_INCLUDE_DIR}"
)
endif()

mark_as_advanced(MvSDK_LIB MvSDK_INCLUDE_DIR)

set(MvSDK_LIBS "mvsdk")
set(MvSDK_INCLUDE_DIRS "${MvSDK_INCLUDE_DIR}")

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
MvSDK
REQUIRED_VARS MvSDK_LIBS MvSDK_INCLUDE_DIRS
REQUIRED_VARS MvSDK_LIB MvSDK_INCLUDE_DIR
)
19 changes: 16 additions & 3 deletions cmake/FindOPTCameraSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,36 @@ set(OPTCameraSDK_root_path "/opt/OPT/OPTCameraDemo")

# add the include directories path
find_path(
OPTCameraSDK_INCLUDE_DIRS
OPTCameraSDK_INCLUDE_DIR
NAMES OPTApi.h OPTDefines.h
PATHS "${OPTCameraSDK_root_path}/include"
NO_DEFAULT_PATH
)

# add libraries
find_library(
OPTCameraSDK_LIBS
OPTCameraSDK_LIB
NAMES "libOPTSDK.so"
PATHS "${OPTCameraSDK_root_path}/lib"
NO_DEFAULT_PATH
)

if(NOT TARGET optcamsdk)
add_library(optcamsdk SHARED IMPORTED)
set_target_properties(optcamsdk PROPERTIES
IMPORTED_LOCATION "${OPTCameraSDK_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${OPTCameraSDK_INCLUDE_DIR}"
)
endif()

mark_as_advanced(OPTCameraSDK_INCLUDE_DIR OPTCameraSDK_LIB)

set(OPTCameraSDK_LIBS "optcamsdk")
set(OPTCameraSDK_INCLUDE_DIRS "${OPTCameraSDK_INCLUDE_DIR}")

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
OPTCameraSDK
REQUIRED_VARS OPTCameraSDK_LIBS OPTCameraSDK_INCLUDE_DIRS
REQUIRED_VARS OPTCameraSDK_LIB OPTCameraSDK_INCLUDE_DIR
)
19 changes: 16 additions & 3 deletions cmake/FindOPTLightCtrl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,36 @@ set(OPTLightCtrl_root_path "/opt/OPT/OPTController")

# add the include directories path
find_path(
OPTLightCtrl_INCLUDE_DIRS
OPTLightCtrl_INCLUDE_DIR
NAMES OPTController.h OPTErrorCode.h
PATHS "${OPTLightCtrl_root_path}/include"
NO_DEFAULT_PATH
)

# add libraries
find_library(
OPTLightCtrl_LIBS
OPTLightCtrl_LIB
NAMES "libOPTController.so"
PATHS "${OPTLightCtrl_root_path}/lib"
NO_DEFAULT_PATH
)

if(NOT TARGET optlc)
add_library(optlc SHARED IMPORTED)
set_target_properties(optlc PROPERTIES
IMPORTED_LOCATION "${OPTLightCtrl_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${OPTLightCtrl_INCLUDE_DIR}"
)
endif()

mark_as_advanced(OPTLightCtrl_INCLUDE_DIR OPTLightCtrl_LIB)

set(OPTLightCtrl_LIBS "optlc")
set(OPTLightCtrl_INCLUDE_DIRS "${OPTLightCtrl_INCLUDE_DIR}")

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
OPTLightCtrl
REQUIRED_VARS OPTLightCtrl_LIBS OPTLightCtrl_INCLUDE_DIRS
REQUIRED_VARS OPTLightCtrl_LIB OPTLightCtrl_INCLUDE_DIR
)
19 changes: 16 additions & 3 deletions cmake/FindOrt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ endif()

# add the include directories path
find_path(
Ort_INCLUDE_DIRS
Ort_INCLUDE_DIR
PATHS "${ort_root_path}/include/onnxruntime"
NAMES cpu_provider_factory.h onnxruntime_run_options_config_keys.h
onnxruntime_c_api.h onnxruntime_session_options_config_keys.h
Expand All @@ -15,15 +15,28 @@ find_path(

# add libraries
find_library(
Ort_LIBS
Ort_LIB
NAMES "libonnxruntime.so"
PATHS "${ort_root_path}/lib"
NO_DEFAULT_PATH
)

if(NOT TARGET onnxruntime)
add_library(onnxruntime SHARED IMPORTED)
set_target_properties(onnxruntime PROPERTIES
IMPORTED_LOCATION "${Ort_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${Ort_INCLUDE_DIR}"
)
endif()

mark_as_advanced(Ort_INCLUDE_DIR Ort_LIB)

set(Ort_LIBS "onnxruntime")
set(Ort_INCLUDE_DIRS "${Ort_INCLUDE_DIR}")

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
Ort
REQUIRED_VARS Ort_LIBS Ort_INCLUDE_DIRS
REQUIRED_VARS Ort_LIB Ort_INCLUDE_DIR
)
61 changes: 16 additions & 45 deletions cmake/RMVLCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -202,69 +202,40 @@ option(BUILD_EXTRA "Build extra modules containing 4 data components and 4 funct
option(BUILD_EXAMPLES "Build RMVL all examples" ON)
option(BUILD_DOCS "Create build rules for RMVL Documentation" OFF)

# ----------------------------------------------------------------------------
# Add compile option
# Note:
# if the condition is met, set to the default value, otherwise set to the reverse value
# Usage:
# __rmvl_option(<option> <description> <default> <IF|OR> <condition>)
# Example:
# __rmvl_option(
# WITH_APRILTAG "Enable apriltag support" ON IF BUILD_APRILTAG
# )
# ----------------------------------------------------------------------------
macro(__rmvl_option _option _desc _value _op _cond)
# unset the option if it is defined
if(DEFINED ${_option})
unset(${_option} CACHE)
endif()
# if
if(${_op} STREQUAL "IF" OR ${_op} STREQUAL "if")
if(${_cond})
set(target_val ${_value})
else()
if(${_value})
set(target_val OFF) # NOT ON -> OFF
else()
set(target_val ON) # NOT OFF -> ON
endif()
endif()
# or
elseif(${_op} STREQUAL "OR" OR ${_op} STREQUAL "or")
if(${_cond} OR ${_value})
set(target_val ON)
else()
set(target_val OFF)
endif()
else()
message(FATAL_ERROR "Unknown operator: ${_op} in the option \"${_option}\"")
endif()
# set the option
option(${_option} ${_desc} ${target_val})
endmacro()

# ----------------------------------------------------------------------------
# 3rdparty options
# ----------------------------------------------------------------------------
# apriltag
option(BUILD_APRILTAG "Build the 3rd party: apriltag" ON)
if(BUILD_APRILTAG)
add_subdirectory(${CMAKE_SOURCE_DIR}/3rdparty/apriltag)
option(WITH_APRILTAG "Enable apriltag support" ON)
else()
unset(WITH_APRILTAG CACHE)
option(WITH_APRILTAG "Enable apriltag support" OFF)
endif()
find_package(apriltag QUIET)
__rmvl_option(WITH_APRILTAG "Enable apriltag support" ${apriltag_FOUND} OR BUILD_APRILTAG)

# open62541
option(BUILD_OPEN62541 "Build the 3rd party: open62541" OFF)
if(BUILD_OPEN62541)
add_subdirectory(${CMAKE_SOURCE_DIR}/3rdparty/open62541)
endif()
find_package(open62541 QUIET)
__rmvl_option(WITH_OPEN62541 "Enable open62541 support" ${open62541_FOUND} OR BUILD_OPEN62541)
if(BUILD_OPEN62541 OR open62541_FOUND)
option(WITH_OPEN62541 "Enable open62541 support" ON)
else()
unset(WITH_OPEN62541 CACHE)
option(WITH_OPEN62541 "Enable open62541 support" OFF)
endif()

# onnxruntime
find_package(Ort QUIET)
__rmvl_option(WITH_ONNXRUNTIME "Enable onnxruntime support" ON IF ${Ort_FOUND})
if(Ort_FOUND)
option(WITH_ONNXRUNTIME "Enable onnxruntime support" ON)
else()
unset(WITH_ONNXRUNTIME CACHE)
option(WITH_ONNXRUNTIME "Enable onnxruntime support" OFF)
endif()

# ----------------------------------------------------------------------------
# Build performance and unit tests
Expand Down
1 change: 1 addition & 0 deletions cmake/RMVLExtraTarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if(NOT TARGET uninstall)
)
add_custom_target(
uninstall
COMMENT "Uninstall all files created by the build process."
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
)
endif()
Loading

0 comments on commit d6a282d

Please sign in to comment.