cmake_minimum_required(VERSION 3.24) project(TargetExposureControl VERSION 1.1.0 LANGUAGES CXX) include(GNUInstallDirs) include(CMakePackageConfigHelpers) find_package(OpenCV 4 REQUIRED COMPONENTS core imgproc) add_library(target_exposure_control STATIC src/config.cpp src/metering.cpp src/history.cpp src/predictor.cpp src/controller.cpp src/exposure_control.cpp) add_library(TargetExposureControl::Control ALIAS target_exposure_control) set_target_properties(target_exposure_control PROPERTIES EXPORT_NAME Control POSITION_INDEPENDENT_CODE ON CXX_EXTENSIONS OFF) target_compile_features(target_exposure_control PUBLIC cxx_std_17) target_include_directories(target_exposure_control PUBLIC $ $) target_link_libraries(target_exposure_control PUBLIC ${OpenCV_LIBS}) function(tec_warnings target) if(MSVC) target_compile_options(${target} PRIVATE /W4 /permissive- /utf-8) else() target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic) endif() endfunction() tec_warnings(target_exposure_control) option(TEC_BUILD_TESTS "Build deterministic offline tests" ${PROJECT_IS_TOP_LEVEL}) option(TEC_BUILD_EXAMPLES "Build the minimal simulated caller" ${PROJECT_IS_TOP_LEVEL}) if(TEC_BUILD_TESTS) enable_testing() add_executable(target_exposure_tests tests/tests.cpp) target_link_libraries(target_exposure_tests PRIVATE TargetExposureControl::Control) tec_warnings(target_exposure_tests) foreach(group IN ITEMS metering stateless history prediction controller states recovery lifecycle feedback config) add_test(NAME tec_${group} COMMAND target_exposure_tests ${group}) set_tests_properties(tec_${group} PROPERTIES TIMEOUT 30) endforeach() endif() if(TEC_BUILD_EXAMPLES) add_executable(target_exposure_example examples/minimal.cpp) target_link_libraries(target_exposure_example PRIVATE TargetExposureControl::Control) tec_warnings(target_exposure_example) if(TEC_BUILD_TESTS) add_test(NAME tec_minimal_example COMMAND target_exposure_example) set_tests_properties(tec_minimal_example PROPERTIES TIMEOUT 30) endif() endif() install(TARGETS target_exposure_control EXPORT TargetExposureControlTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(EXPORT TargetExposureControlTargets NAMESPACE TargetExposureControl:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TargetExposureControl) configure_package_config_file(cmake/TargetExposureControlConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/TargetExposureControlConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TargetExposureControl) write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/TargetExposureControlConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/TargetExposureControlConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/TargetExposureControlConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TargetExposureControl) install(FILES README.md 实施记录.md DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/TargetExposureControl) install(FILES docs/控制与状态说明.md DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/TargetExposureControl/docs) install(FILES examples/minimal.cpp examples/static_station_config.hpp DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/TargetExposureControl/examples)