Skip to content

Commit

Permalink
Leverage global BUILD_TESTING option
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilos authored and neheb committed Jul 21, 2023
1 parent 5631e84 commit b7c45b4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
43 changes: 21 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ if ( EXIV2_ENABLE_EXTERNAL_XMP )
set(EXIV2_ENABLE_XMP OFF)
endif()

if( EXIV2_BUILD_UNIT_TESTS )
if(BUILD_TESTING AND EXIV2_BUILD_UNIT_TESTS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Requires CMake 3.3.3
endif()

Expand All @@ -102,7 +102,7 @@ include(cmake/compilerFlagsExiv2.cmake REQUIRED)

add_subdirectory( src )

if( EXIV2_BUILD_UNIT_TESTS )
if(BUILD_TESTING AND EXIV2_BUILD_UNIT_TESTS)
add_subdirectory ( unitTests )
endif()

Expand All @@ -111,37 +111,36 @@ if( EXIV2_BUILD_FUZZ_TESTS )
endif()

if(EXIV2_BUILD_EXIV2_COMMAND)
add_subdirectory ( app )
add_subdirectory(app)

if( EXIV2_BUILD_SAMPLES )
add_subdirectory( samples )
if(EXIV2_BUILD_SAMPLES)
add_subdirectory(samples)
get_directory_property(SAMPLES DIRECTORY samples DEFINITION APPLICATIONS)

if (Python3_Interpreter_FOUND)
if(BUILD_TESTING AND Python3_Interpreter_FOUND)
add_test(NAME bashTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests)
endif()
endif()
endif()

if (Python3_Interpreter_FOUND)
if(BUILD_TESTING AND Python3_Interpreter_FOUND)
add_test(NAME bugfixTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bugfixes)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bugfixes)
add_test(NAME lensTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose lens_tests)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose lens_tests)
add_test(NAME tiffTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose tiff_test)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose tiff_test)
add_test(NAME versionTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests/version_test.py )
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests/version_test.py )
add_test(NAME regressionTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose regression_tests)
endif()

WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose regression_tests)
endif()
endif()

if( EXIV2_ENABLE_NLS )
Expand Down
8 changes: 5 additions & 3 deletions cmake/findDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ endif()

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")

find_package (Python3 COMPONENTS Interpreter)
if (NOT Python3_Interpreter_FOUND)
message(WARNING "Python3 was not found. Python tests under the 'tests' folder will not be executed")
if(BUILD_TESTING)
find_package(Python3 COMPONENTS Interpreter)
if(NOT Python3_Interpreter_FOUND)
message(WARNING "Python3 was not found. Python tests under the 'tests' folder will not be executed.")
endif()
endif()

find_package(Filesystem COMPONENTS Experimental Final REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion cmake/printSummary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if (WIN32)
endif()
OptionOutput( "Building exiv2 command: " EXIV2_BUILD_EXIV2_COMMAND )
OptionOutput( "Building samples: " EXIV2_BUILD_SAMPLES AND EXIV2_BUILD_EXIV2_COMMAND )
OptionOutput( "Building unit tests: " EXIV2_BUILD_UNIT_TESTS )
OptionOutput( "Building unit tests: " EXIV2_BUILD_UNIT_TESTS AND BUILD_TESTING )
OptionOutput( "Building fuzz tests: " EXIV2_BUILD_FUZZ_TESTS )
OptionOutput( "Building doc: " EXIV2_BUILD_DOC )
OptionOutput( "Building with coverage flags: " BUILD_WITH_COVERAGE )
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Note that this is a hack for testing the internals of the library. If EXIV2_BUILD_UNIT_TESTS==OFF
# Then we only export the symbols that are explicitly exported
if( EXIV2_BUILD_UNIT_TESTS )
if(BUILD_TESTING AND EXIV2_BUILD_UNIT_TESTS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Requires CMake 3.3.3
endif()

Expand Down

0 comments on commit b7c45b4

Please sign in to comment.