11cmake_minimum_required (VERSION 3.18)
2- project (videostrip VERSION 0.7.1 LANGUAGES CXX)
2+ project (videostrip VERSION 0.8.0 LANGUAGES CXX)
33
44set (CMAKE_CXX_STANDARD 17)
55set (CMAKE_CXX_STANDARD_REQUIRED ON )
@@ -15,7 +15,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
1515# Build options
1616# ==========================================
1717option (BUILD_TESTS "Build unit/integration tests" ON )
18- option (BUILD_GUI "Build GUI module" OFF )
18+ # option(BUILD_GUI "Build GUI module" OFF)
19+ option (BUILD_MANPAGE "Generate manpage for CLI tool (requires help2man)" OFF )
1920
2021
2122message (STATUS "--------------------" )
@@ -54,21 +55,45 @@ message(STATUS "OpenCV version: ${OpenCV_VERSION}")
5455message (STATUS "OpenCV include dirs: ${OpenCV_INCLUDE_DIRS} " )
5556
5657# ==========================================
57- # Global include path (so <videostrip_core/...> works everywhere)
58- # ==========================================
59- # All headers live in subfolders inside ${CMAKE_SOURCE_DIR}
60- include_directories (${CMAKE_SOURCE_DIR} )
61-
58+ # yaml-cpp detection. FetchContent fallback
6259# ==========================================
63- # Promoted to top-level as it is needed by multiple modules
64- find_package (yaml-cpp QUIET )
65- if (NOT yaml-cpp_FOUND)
66- message (STATUS "yaml-cpp not found; fetching..." )
60+ find_package (yaml-cpp CONFIG)
61+
62+ if (TARGET yaml-cpp)
63+ message (STATUS "yaml-cpp found (CONFIG package)" )
64+ message (STATUS "yaml-cpp include dirs: ${yaml-cpp_INCLUDE_DIRS}" )
65+ else ()
66+ message (STATUS "yaml-cpp not found (CONFIG package)" )
67+ message (STATUS ">>>> yaml-cpp not found; fetching source with FetchContent..." )
6768 include (FetchContent)
68- FetchContent_Declare(yaml_cpp GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git GIT_TAG 0.8.0)
69+
70+ # Keep the fetched build small & static
71+ set (YAML_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
72+ set (YAML_CPP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
73+ set (YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
74+ set (YAML_CPP_INSTALL OFF CACHE BOOL "" FORCE)
75+ # MSVC runtime per your project policy
76+ set (YAML_MSVC_SHARED_RT ON CACHE BOOL "" FORCE)
77+
78+ FetchContent_Declare(yaml_cpp
79+ GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
80+ GIT_TAG 0.8.0
81+ )
6982 FetchContent_MakeAvailable(yaml_cpp)
7083endif ()
7184
85+ # At this point, a target named 'yaml-cpp' must exist (from either path).
86+ # If not, abort with error.
87+ if (NOT TARGET yaml-cpp)
88+ message (FATAL_ERROR "yaml-cpp target not found even after FetchContent; aborting." )
89+ endif ()
90+
91+ # ==========================================
92+ # Global include path (so <videostrip_core/...> works everywhere)
93+ # ==========================================
94+ # All headers live in subfolders inside ${CMAKE_SOURCE_DIR}
95+ include_directories (${CMAKE_SOURCE_DIR} )
96+
7297# ==========================================
7398# Add project modules (progressive build)
7499# ==========================================
@@ -137,9 +162,6 @@ install(TARGETS videostrip_core
137162 LIBRARY DESTINATION lib
138163)
139164
140- # TODO: Minimal manpage (optional). We do not have one yet, generate with help2man later.
141- # install(FILES packaging/videostrip.1 DESTINATION share/man/man1)
142-
143165# Public headers (install only .hpp files from videostrip_core/)
144166# If the headers live in subdirs (feature/, logging/), this will include them.
145167install (DIRECTORY ${CMAKE_SOURCE_DIR} /videostrip_core/
@@ -154,6 +176,37 @@ install(FILES configs/sample_config.yaml
154176install (FILES ${CMAKE_SOURCE_DIR} /README.md ${CMAKE_SOURCE_DIR} /LICENSE
155177 DESTINATION share/doc /videostrip
156178)
179+ # -------------------------
180+ # Manpage generation (optional)
181+ # -------------------------
182+ if (BUILD_MANPAGE)
183+ message (STATUS "Manpage generation enabled" )
184+ find_program (HELP2MAN_EXECUTABLE help2man)
185+
186+ if (HELP2MAN_EXECUTABLE)
187+ # Create packaging dir if it does not exist
188+ file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR} /packaging)
189+ add_custom_command (
190+ OUTPUT ${CMAKE_BINARY_DIR} /packaging/videostrip.1
191+ COMMAND ${HELP2MAN_EXECUTABLE} --no -discard-stderr --output =${CMAKE_BINARY_DIR} /packaging/videostrip.1 $<TARGET_FILE:videostrip_cli>
192+ DEPENDS videostrip_cli
193+ COMMENT "Generating manpage for videostrip_cli"
194+ VERBATIM
195+ )
196+
197+ add_custom_target (manpage ALL
198+ DEPENDS ${CMAKE_BINARY_DIR} /packaging/videostrip.1
199+ )
200+
201+ install (FILES ${CMAKE_BINARY_DIR} /packaging/videostrip.1 DESTINATION share/man/man1)
202+ else ()
203+ message (WARNING "help2man not found: manpage will not be generated automatically." )
204+ endif ()
205+
206+ else ()
207+ message (STATUS "Manpage generation disabled" )
208+ endif ()
209+
157210
158211# -------------------------
159212# CPack configuration
@@ -175,20 +228,17 @@ set(CPACK_PACKAGE_FILE_NAME
175228# Source + binary archives
176229set (CPACK_GENERATOR "TGZ;ZIP;DEB" )
177230
178- # Debian metadata (tune as you learn your shared libs)
231+ # Debian metadata (tune as we expand shared libs)
179232set (CPACK_DEBIAN_PACKAGE_MAINTAINER "Jose Cappelletto" ) # required
180233set (CPACK_DEBIAN_PACKAGE_SECTION "science" )
181234set (CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} )
182235
183236# Runtime deps if linking dynamically; keep minimal first, then refine with ldd
184- # Example:
185237set (CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++6, libgcc-s1" )
186- # TODO:
187- # Add correct libraries from OpenCV
188- # set(CPACK_DEBIAN_PACKAGE_DEPENDS "libopencv-core4.8, libopencv-imgcodecs4.8")
238+ # Automate depedencies based on linked shared libs
189239set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
190240# Avoid the classic error: ensure CPack knows the project
191241set (CPACK_PACKAGE_FILE_NAME "videostrip-${PROJECT_VERSION} -${CMAKE_SYSTEM_NAME} -${CMAKE_SYSTEM_PROCESSOR} " )
192242
193243include (CPack)
194- # End of CPack configuration
244+ # End of CPack configuration
0 commit comments