Skip to content

Latest commit

 

History

History
99 lines (69 loc) · 4.64 KB

building.md

File metadata and controls

99 lines (69 loc) · 4.64 KB

Building CZICheck

overview

The CZICheck-project is using the CMake build system. It is a cross-platform build system that can generate native build files for many platforms and IDEs. The following external packages are required for building.

component description referenced via comment
cli11 command line parser CMake's FetchContent
libCZI CZI file format library CMake's FetchContent
XercesC validating XML parser CMake's find_package If the XercesC-package cannot be found, the checker "xmlmetadataschema" will be disabled and not be available.

building

Building CZICheck is done by running those commands. Assume that the current working directory is the root of the CZICheck-project.

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release

When running the CMake-configure step, a line stating whether the XercesC-package was found or not will be printed.

If it is not found, you will find a line

XercesC library not found, the checker 'xmlmetadataschema' will **not** be available

whereas if it was found, it will read

XercesC library available -> version: 3.2.4
XercesC library found, the checker 'xmlmetadataschema' will be available

The resulting binary is then located in the build/CZICheck directory.

A recording of the build process is available here.

installing the XercesC-package

For installing the XercesC-package it is recommended to use the package-manager of your operating system.

For example, on Ubuntu XercesC can be installed by running

sudo apt-get install libxerces-c-dev

On Windows, the vcpkg-package-manager can be used. Running this command will install the XercesC-package (adjust the triplet to your configuration).

vcpkg install xerces-c --triplet x64-windows-static

running the tests

For configuring the tests, the CMake-option CZICHECK_BUILD_TESTS has to be set to ON. This can be done by adding the option to the CMake-configure step.

cmake .. -DCMAKE_BUILD_TYPE=Release -DCZICHECK_BUILD_TESTS=ON

During the CMake-run, the test-data will be downloaded (to the build-directory) and the tests will be configured.

The tests can then be run by executing the following command in the build-directory.

ctest -C Release

adding new tests

  1. In the CZICheck (${PROJECT_SOURCE_DIR}/CZICheck) CMakeLists.txt make sure the respective image file to be used for testing is present in one of the "data feeds" given in ExternalData_URL_TEMPLATES

  2. In the ExternalData_Add_Test ensure that the testdata is copied to the build directory by adding something like -r myfile.czi=DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Test/CZICheckSamples/myfile.czi}

  3. Assuming the czi-file to be tested is called myfile.czi

    1. Add ${PROJECT_SOURCE_DIR}/Test/CZICheckSamples/myfile.czi.md5. The content of this file is the MD5-hash of myfile.czi (that was generated by the remote test-data feed).
    2. Add ${PROJECT_SOURCE_DIR}/Test/CZICheckSamples/myfile-expectation.txt. The content should be the output of the CZICheck executable when checking myfile.czi.
    3. In the file ${PROJECT_SOURCE_DIR}/Test/CZICheckSamples/TestCasesLists.txt, add the line myfile.czi,<#exit-code>,myfile-expectation.txt (where <#exit-code> should be a number indicating the expected exit-code of the program).
  4. To create a testoutput add something like -o ${PROJECT_SOURCE_DIR}/testoutputs to the COMMAND. The complete cmake block should then look like e.g. (the directory "testoutputs" has to exist):

    ExternalData_Add_Test(Test_CZICheck
      NAME Test-CZICheck
      COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/CZICheckRunTests.py
      --executable $<TARGET_FILE:CZICheck>
      --knowngoodresultspath ${CMAKE_CURRENT_SOURCE_DIR}/../Test/CZICheckSamples
      --test_list ${CMAKE_CURRENT_SOURCE_DIR}/../Test/CZICheckSamples/TestCasesLists.txt
      -o ${PROJECT_SOURCE_DIR}/testoutputs # save outputs for each file; the directory "testoutputs" has to exist
      -r #....truncated! All test images are listed here
      # add your new file to the end
      -r myfile.czi=DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Test/CZICheckSamples/myfile.czi}
      }
    )