[libcamera-devel] [SimpleCam PATCH v2] cmake: Provide a sample CMakeLists.txt
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Aug 9 16:02:36 CEST 2022
Hi Kieran,
Thank you for the patch.
On Tue, Aug 09, 2022 at 02:44:23PM +0100, Kieran Bingham via libcamera-devel wrote:
> While libcamera uses meson as its build infrastructure, applications are
> free to use other make systems. CMake is widely used, so add an example
> CMakeLists.txt to support building simple-cam and linking against
> libcamera using cmake.
>
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> v2:
> - Add compiler flags
> - Fix 'it's'
> - Remove stray leftovers
> - Remove version number
>
> CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
> create mode 100644 CMakeLists.txt
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> new file mode 100644
> index 000000000000..2a86b55ebeea
> --- /dev/null
> +++ b/CMakeLists.txt
> @@ -0,0 +1,32 @@
> +cmake_minimum_required(VERSION 3.6)
> +
> +project(SimpleCam
> + DESCRIPTION "A small and documented example application for libcamera"
> + LANGUAGES CXX)
> +
> +set (CMAKE_CXX_STANDARD 17)
> +
> +set (CMAKE_CXX_FLAGS "-Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -Wno-unused-parameter")
> +
> +find_package(PkgConfig)
> +
> +pkg_check_modules(LIBCAMERA REQUIRED IMPORTED_TARGET libcamera)
> +message(STATUS "libcamera library found:")
> +message(STATUS " version: ${LIBCAMERA_VERSION}")
> +message(STATUS " libraries: ${LIBCAMERA_LINK_LIBRARIES}")
> +message(STATUS " include path: ${LIBCAMERA_INCLUDE_DIRS}")
> +
> +# libevent is used specifically by simple-cam as its event loop.
> +# Applications may use a different event handling implementation.
> +pkg_check_modules(LIBEVENT REQUIRED IMPORTED_TARGET libevent_pthreads)
> +message(STATUS "libevent_pthreads library found:")
> +message(STATUS " version: ${LIBEVENT_VERSION}")
> +message(STATUS " libraries: ${LIBEVENT_LINK_LIBRARIES}")
> +message(STATUS " include path: ${LIBEVENT_INCLUDE_DIRS}")
> +
> +include_directories(${CMAKE_SOURCE_DIR} ${LIBCAMERA_INCLUDE_DIRS} ${LIBEVENT_INCLUDE_DIRS})
> +
> +add_executable(simple-cam simple-cam.cpp event_loop.cpp)
> +
> +target_link_libraries(simple-cam PkgConfig::LIBEVENT)
> +target_link_libraries(simple-cam PkgConfig::LIBCAMERA)
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list