Skip to content

Commit

Permalink
Add CTest support and option for minimum progs
Browse files Browse the repository at this point in the history
  • Loading branch information
cho-m committed Nov 2, 2024
1 parent e36609f commit db39664
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ jobs:
- name: Build
# Build your program with the given configuration
run: sudo cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install

- name: Test
run: ctest --test-dir ${{github.workspace}}/build

1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ project(
leptonica
LANGUAGES C
VERSION 1.85.1)
include(CTest)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)

Expand Down
34 changes: 27 additions & 7 deletions prog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
option(ONLY_INSTALL_PROG "Build only installed programs" OFF)

set(math_progs "blend4_reg|dna_reg|extrema_reg|insert_reg|locminmax_reg|numa1_reg|otsutest1|pixalloc_reg|plottest|pta_reg|rankhisto_reg|rotatefastalt|watershed_reg")

set (INSTALL_PROGS
convertfilestopdf convertfilestops
convertformat convertsegfilestopdf convertsegfilestops
converttopdf converttops fileinfo imagetops xtractprotos
)

set (MANUAL_REG_PROGS
alltests_reg bilateral1_reg
binmorph2_reg binmorph4_reg binmorph5_reg
dwamorph2_reg
files_reg fmorphauto_reg
morphseq_reg pixalloc_reg pixtile_reg
smoothedge_reg
)

file(RELATIVE_PATH relative_reg_dir ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

########################################
# FUNCTION add_prog_target
########################################
function(add_prog_target target)
if(ONLY_INSTALL_PROG AND NOT target IN_LIST INSTALL_PROGS)
return()
endif()
set (${target}_src "${ARGN}")
add_executable (${target} ${${target}_src})
string(FIND ${target} "gif" GIF_TEST_FOUND)
Expand All @@ -15,12 +36,17 @@ function(add_prog_target target)
if (BUILD_SHARED_LIBS)
target_compile_definitions (${target} PRIVATE -DLIBLEPT_IMPORTS)
endif()
if(FREEBSD AND HAVE_LIBM AND ${target} MATCHES ${math_progs})
if(HAVE_LIBM AND ${target} MATCHES ${math_progs})
target_link_libraries (${target} leptonica m)
else()
target_link_libraries (${target} leptonica)
endif()
set_target_properties (${target} PROPERTIES FOLDER prog)
if(${target} MATCHES "_reg$" AND NOT target IN_LIST MANUAL_REG_PROGS)
add_test(NAME ${target}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/reg_wrapper.sh ${relative_reg_dir}/${target}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
endfunction(add_prog_target)
########################################

Expand Down Expand Up @@ -327,12 +353,6 @@ add_prog_target(writemtiff writemtiff.c)
add_prog_target(xtractprotos xtractprotos.c)
add_prog_target(yuvtest yuvtest.c)

set (INSTALL_PROGS
convertfilestopdf convertfilestops
convertformat convertsegfilestopdf convertsegfilestops
converttopdf converttops fileinfo imagetops xtractprotos
)

foreach(make_install ${INSTALL_PROGS})
install(TARGETS ${make_install} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
endforeach()

0 comments on commit db39664

Please sign in to comment.