function(boost_nowide_add_test name) cmake_parse_arguments(PARSE_ARGV 1 ARG "COMPILE_ONLY" "SRC" "LIBRARIES;DEFINITIONS;ARGS") if(NOT ARG_SRC) set(ARG_SRC ${name}.cpp) endif() set(name ${PROJECT_NAME}-${name}) add_executable(${name} ${ARG_SRC}) target_link_libraries(${name} PRIVATE Boost::nowide ${ARG_LIBRARIES}) boost_add_warnings(${name} pedantic ${Boost_NOWIDE_WERROR}) target_compile_definitions(${name} PRIVATE BOOST_ALL_NO_LIB ${ARG_DEFINITIONS}) if(NOT ARG_COMPILE_ONLY) add_test(NAME ${name} COMMAND ${name} ${ARG_ARGS}) endif() endfunction() boost_nowide_add_test(test_codecvt) boost_nowide_add_test(test_convert) boost_nowide_add_test(test_env) boost_nowide_add_test(test_env_win SRC test_env.cpp DEFINITIONS BOOST_NOWIDE_TEST_INCLUDE_WINDOWS) boost_nowide_add_test(test_fstream) boost_nowide_add_test(test_fstream_cxx11) boost_nowide_add_test(test_iostream) boost_nowide_add_test(test_stackstring) boost_nowide_add_test(test_stdio) boost_nowide_add_test(test_system_n SRC test_system.cpp DEFINITIONS BOOST_NOWIDE_TEST_USE_NARROW=1) if(WIN32) boost_nowide_add_test(test_system_w SRC test_system.cpp DEFINITIONS BOOST_NOWIDE_TEST_USE_NARROW=0) else() boost_nowide_add_test(test_internal_fstream SRC test_fstream.cpp DEFINITIONS BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT=1) boost_nowide_add_test(test_internal_fstream_cxx11 SRC test_fstream_cxx11.cpp DEFINITIONS BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT=1) endif() if(NOT BOOST_SUPERPROJECT_SOURCE_DIR) find_package(Boost 1.56 REQUIRED COMPONENTS filesystem system chrono) endif() boost_nowide_add_test(test_fs LIBRARIES Boost::filesystem) boost_nowide_add_test(benchmark_fstream COMPILE_ONLY DEFINITIONS BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT=1 LIBRARIES Boost::chrono)