Skip to content

Commit

Permalink
add new -DBUILD_UTILS option to cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
jbathegit committed Jun 14, 2024
1 parent 5dbbbcb commit 6995698
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 33 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ project(
option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF)
option(ENABLE_PYTHON "Enable building python module 'ncepbufr'" OFF)
option(BUILD_SHARED_LIBS "Enable building shared libraries" OFF)
option(BUILD_UTILS "Enable building utilities" ON)
option(BUILD_TESTING "Enable automated testing" ON)

# Developers can use this option to specify a local directory which
# holds the test files. They will be copied instead of fetching the
Expand Down Expand Up @@ -105,7 +107,10 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
endif()

add_subdirectory(src)
add_subdirectory(utils)

if(BUILD_UTILS)
add_subdirectory(utils)
endif()

if(ENABLE_PYTHON)
add_subdirectory(python)
Expand All @@ -114,8 +119,8 @@ endif()
add_subdirectory(tables)

# Turn on unit testing.
include(CTest)
if(BUILD_TESTING)
include(CTest)
add_subdirectory(test)
endif()

Expand Down
64 changes: 33 additions & 31 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,21 @@ create_c_test_plain(test_c_crwbmg)
# Install testing scripts
list(APPEND test_scripts
test_outtest.sh
test_gettab.sh
test_binv.sh
test_sinv.sh
test_readbp.sh
test_readmp.sh
test_cmpbqm.sh
test_split_by_subset.sh
test_debufr.sh
test_xbfmg.sh
test_apxdx.sh
)

# Run the test scripts for the utils.
if(BUILD_UTILS)
list(APPEND test_scripts
test_gettab.sh
test_binv.sh
test_sinv.sh
test_readbp.sh
test_readmp.sh
test_cmpbqm.sh
test_split_by_subset.sh
test_debufr.sh
test_xbfmg.sh
test_apxdx.sh
)
endif()
foreach(test_script ${test_scripts})
execute_process( COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/test_scripts/${test_script}
Expand Down Expand Up @@ -179,22 +181,22 @@ foreach(test_src ${test_c_interface_srcs})
add_test(NAME ${test} COMMAND ${CMAKE_BINARY_DIR}/test/${test_exe})
endforeach()

# These are the utilities to be tested.
list(APPEND utils
debufr
gettab
sinv
binv
split_by_subset
readbp
readmp
cmpbqm
xbfmg
apxdx
)

# utility tests
foreach(util ${utils})
set(test test_${util})
add_test(NAME ${test} COMMAND ${CMAKE_BINARY_DIR}/bin/${test}.sh)
endforeach()
if(BUILD_UTILS)
# These are the utilities to be tested
list(APPEND utils
debufr
gettab
sinv
binv
split_by_subset
readbp
readmp
cmpbqm
xbfmg
apxdx
)
foreach(util ${utils})
set(test test_${util})
add_test(NAME ${test} COMMAND ${CMAKE_BINARY_DIR}/bin/${test}.sh)
endforeach()
endif()

0 comments on commit 6995698

Please sign in to comment.