CMakeLists.txt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Copyright 2019 Mike Dev
  2. # Distributed under the Boost Software License, Version 1.0.
  3. # See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
  4. #
  5. # NOTE: CMake support for Boost.Ratio is currently experimental at best
  6. # and this file runs only a subset of the unit tests
  7. # (in particular none of the fail tests)
  8. ## unit tests
  9. # list of tests that contain a main function
  10. set( exec_test_files ratio_ext_pass;ratio_io_pass;ratio_pass )
  11. file( GLOB_RECURSE test_files *_pass.cpp )
  12. foreach( file IN LISTS test_files )
  13. get_filename_component( core_name ${file} NAME_WE )
  14. set( test_name test_boost_ratio_${core_name} )
  15. if( ${core_name} IN_LIST exec_test_files )
  16. add_executable( ${test_name} ${file} )
  17. add_test( NAME ${test_name} COMMAND ${test_name} )
  18. else()
  19. # most tests are compile only, so we just need to create an object file
  20. # in order to see, if it compiles
  21. add_library( ${test_name} STATIC ${file})
  22. endif()
  23. target_link_libraries( ${test_name} PUBLIC
  24. Boost::ratio
  25. )
  26. endforeach()
  27. ## examples
  28. file( GLOB_RECURSE test_files ../example/*.cpp )
  29. foreach( file IN LISTS test_files )
  30. get_filename_component( core_name ${file} NAME_WE )
  31. set( test_name test_boost_ratio_${core_name} )
  32. add_executable( ${test_name} ${file} )
  33. target_link_libraries( ${test_name} PUBLIC
  34. Boost::ratio
  35. )
  36. add_test( NAME ${test_name} COMMAND ${test_name} )
  37. endforeach()