function (fortran_library name)
  add_subdirectory(
    "${CMAKE_CURRENT_SOURCE_DIR}/subdir"
    "${CMAKE_CURRENT_BINARY_DIR}/${name}_${${name}}")
endfunction ()

# URL encoding works
set(percent_path "with%sign")
fortran_library(percent_path)

# but is not confused
set(percent_path_confuse "with%25sign")
fortran_library(percent_path_confuse)

# UTF-8 module output path.
set(utf8_path "mödülës")
fortran_library(utf8_path)

# WTF-8 module output path (UTF-8 surrogate half 0xD800).
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/wtf8_path" wtf8_path)
fortran_library(wtf8_path)

# The following tests use non-Unicode output paths, but these platforms are
# unhappy about that.
if (WIN32 OR APPLE)
  continue ()
endif ()

# Binary module output path (0xF2).
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/binary_path" binary_path)
fortran_library(binary_path)

# Latin-1 (ISO-8859-1) module output path. (é 0xE9)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/latin1_path" latin1_path)
fortran_library(latin1_path)

# Byte array example from
# https://stackoverflow.com/questions/37155417/string-encoding-conversion-utf-8-to-shift-jis/42136502#42136502
# Shift-JIS module output path. (ピ ー タ 0x83 0x73  0x81 0x5b  0x83 0x5e)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/shift_jis_path" shift_jis_path)
fortran_library(shift_jis_path)
