Commit bbc38262 by Maarten L. Hekkelman

setting up tests in cmake

parent caeafd31
...@@ -93,7 +93,7 @@ set(THREADS_PREFER_PTHREAD_FLAG) ...@@ -93,7 +93,7 @@ set(THREADS_PREFER_PTHREAD_FLAG)
find_package(Threads) find_package(Threads)
set (Boost_DETAILED_FAILURE_MSG ON) set (Boost_DETAILED_FAILURE_MSG ON)
find_package(Boost 1.71.0 REQUIRED COMPONENTS system iostreams regex date_time) find_package(Boost 1.71.0 REQUIRED COMPONENTS system iostreams regex date_time program_options)
find_package(ZLIB) find_package(ZLIB)
find_package(BZip2) find_package(BZip2)
...@@ -184,15 +184,9 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") ...@@ -184,15 +184,9 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_link_options(cifpp PRIVATE -undefined dynamic_lookup) target_link_options(cifpp PRIVATE -undefined dynamic_lookup)
endif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") endif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# if(NOT EXISTS)
# configure_file(${PROJECT_SOURCE_DIR}/src/revision.hpp.in revision.hpp @ONLY)
# download the components.cif file from CCD # download the components.cif file from CCD
set(COMPONENTS_CIF ${PROJECT_SOURCE_DIR}/data/components.cif) set(COMPONENTS_CIF ${PROJECT_SOURCE_DIR}/data/components.cif)
# unfortunately, extract_archive does not recognize .gz files on Windows?
if (NOT EXISTS ${COMPONENTS_CIF}) if (NOT EXISTS ${COMPONENTS_CIF})
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/data) if (NOT EXISTS ${PROJECT_SOURCE_DIR}/data)
...@@ -229,20 +223,6 @@ add_compile_definitions(CACHE_DIR="${SHARE_INSTALL_DIR}/libcifpp" DATA_DIR="${SH ...@@ -229,20 +223,6 @@ add_compile_definitions(CACHE_DIR="${SHARE_INSTALL_DIR}/libcifpp" DATA_DIR="${SH
configure_file(${PROJECT_SOURCE_DIR}/src/Config-cmake.hpp.in Config.hpp) configure_file(${PROJECT_SOURCE_DIR}/src/Config-cmake.hpp.in Config.hpp)
# Unit test
add_executable(unit-test ${PROJECT_SOURCE_DIR}/test/unit-test.cpp Config.hpp)
if(${ZLIB_FOUND})
target_link_libraries(unit-test ZLIB::ZLIB)
endif()
if(${BZip2_FOUND})
target_link_libraries(unit-test BZip2::BZip2)
endif()
target_link_libraries(unit-test cifpp_static Threads::Threads ${Boost_LIBRARIES})
generate_export_header(cifpp) generate_export_header(cifpp)
# Install rules # Install rules
...@@ -276,7 +256,7 @@ install(FILES ...@@ -276,7 +256,7 @@ install(FILES
set(INCLUDE_INSTALL_DIR include ) set(INCLUDE_INSTALL_DIR include )
set(LIBRARY_INSTALL_DIR lib ) set(LIBRARY_INSTALL_DIR lib )
set(SHARE_INSTALL_DIR share) set(SHARE_INSTALL_DIR share/libcifpp)
set(ConfigPackageLocation lib/cmake/cifpp) set(ConfigPackageLocation lib/cmake/cifpp)
...@@ -310,3 +290,63 @@ install( ...@@ -310,3 +290,63 @@ install(
DESTINATION ${ConfigPackageLocation} DESTINATION ${ConfigPackageLocation}
COMPONENT Devel COMPONENT Devel
) )
# Unit tests
option(CIFPP_BUILD_TESTS "Build test exectuables" OFF)
if(CIFPP_BUILD_TESTS)
if(USE_RSRC)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cifpp_test_rsrc.obj
COMMAND ${MRC} -o ${CMAKE_CURRENT_BINARY_DIR}/cifpp_test_rsrc.obj ${CMAKE_SOURCE_DIR}/rsrc/mmcif_pdbx_v50.dic ${COFF_SPEC}
)
set(CIFPP_TEST_RESOURCE ${CMAKE_CURRENT_BINARY_DIR}/cifpp_test_rsrc.obj)
endif()
list(APPEND CIFPP_tests
# pdb2cif
rename-compound
unit)
foreach(CIFPP_TEST IN LISTS CIFPP_tests)
set(CIFPP_TEST "${CIFPP_TEST}-test")
set(CIFPP_TEST_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/test/${CIFPP_TEST}.cpp")
add_executable(${CIFPP_TEST} ${CIFPP_TEST_SOURCE} ${CIFPP_TEST_RESOURCE})
target_include_directories(${CIFPP_TEST} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR} # for config.h
)
target_link_libraries(${CIFPP_TEST} cifpp_static Threads::Threads ${Boost_LIBRARIES})
if(${ZLIB_FOUND})
target_link_libraries(${CIFPP_TEST} ZLIB::ZLIB)
endif()
if(${BZip2_FOUND})
target_link_libraries(${CIFPP_TEST} BZip2::BZip2)
endif()
if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
target_compile_options(${CIFPP_TEST} PRIVATE /EHsc)
endif()
add_custom_target("run-${CIFPP_TEST}" DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Run${CIFPP_TEST}.touch ${CIFPP_TEST})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Run${CIFPP_TEST}.touch
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CIFPP_TEST}
)
add_test(NAME ${CIFPP_TEST}
COMMAND $<TARGET_FILE:${CIFPP_TEST}>
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
endforeach()
endif()
#if __has_include("../src/Config.hpp") #include "Config.hpp"
#include "../src/Config.hpp"
#endif
#include "../include/cif++/Cif++.hpp" #include "../include/cif++/Cif++.hpp"
#include "../include/cif++/PDB2Cif.hpp" #include "../include/cif++/PDB2Cif.hpp"
...@@ -17,7 +16,7 @@ int main(int argc, char* argv[]) ...@@ -17,7 +16,7 @@ int main(int argc, char* argv[])
{ {
using namespace std::literals; using namespace std::literals;
po::options_description desc("pdb2cif-test "s + PACKAGE_VERSION + " options"); po::options_description desc("pdb2cif-test options");
desc.add_options() desc.add_options()
("input,i", po::value<std::string>(), "Input file") ("input,i", po::value<std::string>(), "Input file")
("help,h", "Display help message") ("help,h", "Display help message")
......
...@@ -1606,6 +1606,8 @@ PRO OXT HXT SING N N 17 ...@@ -1606,6 +1606,8 @@ PRO OXT HXT SING N N 17
mmcif::File file(example.string()); mmcif::File file(example.string());
mmcif::Structure structure(file); mmcif::Structure structure(file);
(void)file.file().isValid();
mmcif::BondMap bm(structure); mmcif::BondMap bm(structure);
// Test the bonds of the first three residues, that's PRO A 1, ASN A 2, PHE A 3 // Test the bonds of the first three residues, that's PRO A 1, ASN A 2, PHE A 3
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment