diff --git a/CMakeLists.txt b/CMakeLists.txt index aed47f2b59..e2a27ce6cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() @@ -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() @@ -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 ) diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index 5ee481d1cf..393138d26b 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -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) diff --git a/cmake/printSummary.cmake b/cmake/printSummary.cmake index 854323ba05..224524110a 100644 --- a/cmake/printSummary.cmake +++ b/cmake/printSummary.cmake @@ -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 ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1abc7eac20..c7f7372644 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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()