Leverage global BUILD_TESTING option

main
Miloš Komarčević 2 years ago committed by Rosen Penev
parent 5631e84237
commit b7c45b49aa

@ -79,7 +79,7 @@ if ( EXIV2_ENABLE_EXTERNAL_XMP )
set(EXIV2_ENABLE_XMP OFF) set(EXIV2_ENABLE_XMP OFF)
endif() 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 set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Requires CMake 3.3.3
endif() endif()
@ -102,7 +102,7 @@ include(cmake/compilerFlagsExiv2.cmake REQUIRED)
add_subdirectory( src ) add_subdirectory( src )
if( EXIV2_BUILD_UNIT_TESTS ) if(BUILD_TESTING AND EXIV2_BUILD_UNIT_TESTS)
add_subdirectory ( unitTests ) add_subdirectory ( unitTests )
endif() endif()
@ -111,37 +111,36 @@ if( EXIV2_BUILD_FUZZ_TESTS )
endif() endif()
if(EXIV2_BUILD_EXIV2_COMMAND) if(EXIV2_BUILD_EXIV2_COMMAND)
add_subdirectory ( app ) add_subdirectory(app)
if( EXIV2_BUILD_SAMPLES ) if(EXIV2_BUILD_SAMPLES)
add_subdirectory( samples ) add_subdirectory(samples)
get_directory_property(SAMPLES DIRECTORY samples DEFINITION APPLICATIONS) get_directory_property(SAMPLES DIRECTORY samples DEFINITION APPLICATIONS)
if (Python3_Interpreter_FOUND) if(BUILD_TESTING AND Python3_Interpreter_FOUND)
add_test(NAME bashTests add_test(NAME bashTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests) COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests)
endif() endif()
endif() endif()
if (Python3_Interpreter_FOUND) if(BUILD_TESTING AND Python3_Interpreter_FOUND)
add_test(NAME bugfixTests add_test(NAME bugfixTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bugfixes) COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bugfixes)
add_test(NAME lensTests add_test(NAME lensTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose lens_tests) COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose lens_tests)
add_test(NAME tiffTests add_test(NAME tiffTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose tiff_test) COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose tiff_test)
add_test(NAME versionTests add_test(NAME versionTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests 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 ) COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests/version_test.py )
add_test(NAME regressionTests add_test(NAME regressionTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose regression_tests) COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose regression_tests)
endif() endif()
endif() endif()
if( EXIV2_ENABLE_NLS ) if( EXIV2_ENABLE_NLS )

@ -30,9 +30,11 @@ endif()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
find_package (Python3 COMPONENTS Interpreter) if(BUILD_TESTING)
if (NOT Python3_Interpreter_FOUND) find_package(Python3 COMPONENTS Interpreter)
message(WARNING "Python3 was not found. Python tests under the 'tests' folder will not be executed") if(NOT Python3_Interpreter_FOUND)
message(WARNING "Python3 was not found. Python tests under the 'tests' folder will not be executed.")
endif()
endif() endif()
find_package(Filesystem COMPONENTS Experimental Final REQUIRED) find_package(Filesystem COMPONENTS Experimental Final REQUIRED)

@ -65,7 +65,7 @@ if (WIN32)
endif() endif()
OptionOutput( "Building exiv2 command: " EXIV2_BUILD_EXIV2_COMMAND ) OptionOutput( "Building exiv2 command: " EXIV2_BUILD_EXIV2_COMMAND )
OptionOutput( "Building samples: " EXIV2_BUILD_SAMPLES AND 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 fuzz tests: " EXIV2_BUILD_FUZZ_TESTS )
OptionOutput( "Building doc: " EXIV2_BUILD_DOC ) OptionOutput( "Building doc: " EXIV2_BUILD_DOC )
OptionOutput( "Building with coverage flags: " BUILD_WITH_COVERAGE ) OptionOutput( "Building with coverage flags: " BUILD_WITH_COVERAGE )

@ -1,6 +1,6 @@
# Note that this is a hack for testing the internals of the library. If EXIV2_BUILD_UNIT_TESTS==OFF # 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 # 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 set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Requires CMake 3.3.3
endif() endif()

Loading…
Cancel
Save