#===============================================================================
# Setup Project
#===============================================================================

project(ntdtestlibc C)
cmake_minimum_required(VERSION 2.8)

# we don't care about Policy CMP0042 MACOS_RPATH
# turn on CMP0042 default
cmake_policy(SET CMP0042 NEW)

set(PACKAGE_NAME ntdtestlibc)
# raed MUSL version from file
set(PACKAGE_VERSION "0.0.0")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "ntd-test-libc-bugs@undefined.com")

# Add path for custom modules
set(CMAKE_MODULE_PATH
  "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
  ${CMAKE_MODULE_PATH}
  )

# Require out of source build.
include(MacroEnsureOutOfSourceBuild)
MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
 "${PROJECT_NAME} requires an out of source build. Please create a separate
 build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
 )
 
include(MacroListToFlags)
include(FunctionExcludeSourcesFromList)
 
set(NTD_TEST_LIBC_DRIVER_SRC
    linux_main.c
    ntd-test-libc.c
)

# EXCLUDED TESTS:
# 
#   pdclib-tests/functions/stdlib/_Exit.c
#   pdclib-tests/functions/stdlib/abort.c

set(PDCLIB_TESTS_SRC
    pdclib-tests/functions/_PDCLIB/_PDCLIB_atomax.c
    pdclib-tests/functions/_PDCLIB/_PDCLIB_closeall.c
    pdclib-tests/functions/_PDCLIB/_PDCLIB_digits.c
    pdclib-tests/functions/_PDCLIB/_PDCLIB_strtox_main.c
    pdclib-tests/functions/_PDCLIB/_PDCLIB_strtox_prelim.c
    pdclib-tests/functions/_PDCLIB/functions__PDCLIB.c
    pdclib-tests/functions/ctype/functions_ctype.c
    pdclib-tests/functions/ctype/isalnum.c
    pdclib-tests/functions/ctype/isalpha.c
    pdclib-tests/functions/ctype/isblank.c
    pdclib-tests/functions/ctype/iscntrl.c
    pdclib-tests/functions/ctype/isdigit.c
    pdclib-tests/functions/ctype/isgraph.c
    pdclib-tests/functions/ctype/islower.c
    pdclib-tests/functions/ctype/isprint.c
    pdclib-tests/functions/ctype/ispunct.c
    pdclib-tests/functions/ctype/isspace.c
    pdclib-tests/functions/ctype/isupper.c
    pdclib-tests/functions/ctype/isxdigit.c
    pdclib-tests/functions/ctype/tolower.c
    pdclib-tests/functions/ctype/toupper.c
    pdclib-tests/functions/inttypes/functions_inttypes.c
    pdclib-tests/functions/inttypes/imaxabs.c
    pdclib-tests/functions/inttypes/imaxdiv.c
    pdclib-tests/functions/inttypes/strtoimax.c
    pdclib-tests/functions/inttypes/strtoumax.c
    pdclib-tests/functions/locale/_PDCLIB_mb_cur_max.c
    pdclib-tests/functions/locale/_PDCLIB_unicodedata.c
    pdclib-tests/functions/locale/freelocale.c
    pdclib-tests/functions/locale/functions_locale.c
    pdclib-tests/functions/locale/localeconv.c
    pdclib-tests/functions/locale/setlocale.c
    pdclib-tests/functions/locale/uselocale.c
    pdclib-tests/functions/stdio/_cbprintf.c
    pdclib-tests/functions/stdio/_PDCLIB_filemode.c
    pdclib-tests/functions/stdio/_PDCLIB_fillbuffer.c
    pdclib-tests/functions/stdio/_PDCLIB_flushbuffer.c
    pdclib-tests/functions/stdio/_PDCLIB_ftell64.c
    pdclib-tests/functions/stdio/_PDCLIB_fvopen.c
    pdclib-tests/functions/stdio/_PDCLIB_prepread.c
    pdclib-tests/functions/stdio/_PDCLIB_prepwrite.c
    pdclib-tests/functions/stdio/_PDCLIB_print.c
    pdclib-tests/functions/stdio/_PDCLIB_scan.c
    pdclib-tests/functions/stdio/_PDCLIB_seek.c
    pdclib-tests/functions/stdio/_vcbprintf.c
    pdclib-tests/functions/stdio/clearerr.c
    pdclib-tests/functions/stdio/fclose.c
    pdclib-tests/functions/stdio/feof.c
    pdclib-tests/functions/stdio/ferror.c
    pdclib-tests/functions/stdio/fflush.c
    pdclib-tests/functions/stdio/fgetc.c
    pdclib-tests/functions/stdio/fgetpos.c
    pdclib-tests/functions/stdio/fgets.c
    pdclib-tests/functions/stdio/flockfile.c
    pdclib-tests/functions/stdio/fopen.c
    pdclib-tests/functions/stdio/fprintf.c
    pdclib-tests/functions/stdio/fputc.c
    pdclib-tests/functions/stdio/fputs.c
    pdclib-tests/functions/stdio/fread.c
    pdclib-tests/functions/stdio/freopen.c
    pdclib-tests/functions/stdio/fscanf.c
    pdclib-tests/functions/stdio/fseek.c
    pdclib-tests/functions/stdio/fsetpos.c
    pdclib-tests/functions/stdio/ftell.c
    pdclib-tests/functions/stdio/ftrylockfile.c
    pdclib-tests/functions/stdio/functions_stdio.c
    pdclib-tests/functions/stdio/funlockfile.c
    pdclib-tests/functions/stdio/fwrite.c
    pdclib-tests/functions/stdio/getc.c
    pdclib-tests/functions/stdio/getchar.c
    pdclib-tests/functions/stdio/gets.c
    pdclib-tests/functions/stdio/perror.c
    pdclib-tests/functions/stdio/printf.c
    pdclib-tests/functions/stdio/putc.c
    pdclib-tests/functions/stdio/putchar.c
    pdclib-tests/functions/stdio/puts.c
    pdclib-tests/functions/stdio/rename.c
    pdclib-tests/functions/stdio/rewind.c
    pdclib-tests/functions/stdio/scanf.c
    pdclib-tests/functions/stdio/setbuf.c
    pdclib-tests/functions/stdio/setvbuf.c
    pdclib-tests/functions/stdio/snprintf.c
    pdclib-tests/functions/stdio/sprintf.c
    pdclib-tests/functions/stdio/sscanf.c
    pdclib-tests/functions/stdio/tmpnam.c
    pdclib-tests/functions/stdio/ungetc.c
    pdclib-tests/functions/stdio/vfprintf.c
    pdclib-tests/functions/stdio/vfscanf.c
    pdclib-tests/functions/stdio/vprintf.c
    pdclib-tests/functions/stdio/vscanf.c
    pdclib-tests/functions/stdio/vsnprintf.c
    pdclib-tests/functions/stdio/vsprintf.c
    pdclib-tests/functions/stdio/vsscanf.c
    pdclib-tests/functions/stdlib/abs.c
    pdclib-tests/functions/stdlib/atoi.c
    pdclib-tests/functions/stdlib/atol.c
    pdclib-tests/functions/stdlib/atoll.c
    pdclib-tests/functions/stdlib/bsearch.c
    pdclib-tests/functions/stdlib/div.c
    pdclib-tests/functions/stdlib/functions_stdlib.c
    pdclib-tests/functions/stdlib/labs.c
    pdclib-tests/functions/stdlib/ldiv.c
    pdclib-tests/functions/stdlib/llabs.c
    pdclib-tests/functions/stdlib/lldiv.c
    pdclib-tests/functions/stdlib/qsort.c
    pdclib-tests/functions/stdlib/rand.c
    pdclib-tests/functions/stdlib/srand.c
    pdclib-tests/functions/stdlib/strtol.c
    pdclib-tests/functions/stdlib/strtoll.c
    pdclib-tests/functions/stdlib/strtoul.c
    pdclib-tests/functions/stdlib/strtoull.c
    pdclib-tests/functions/string/functions_string.c
    pdclib-tests/functions/string/memchr.c
    pdclib-tests/functions/string/memcmp.c
    pdclib-tests/functions/string/memcpy.c
    pdclib-tests/functions/string/memmove.c
    pdclib-tests/functions/string/memset.c
    pdclib-tests/functions/string/strcat.c
    pdclib-tests/functions/string/strchr.c
    pdclib-tests/functions/string/strcmp.c
    pdclib-tests/functions/string/strcoll.c
    pdclib-tests/functions/string/strcpy.c
    pdclib-tests/functions/string/strcspn.c
    pdclib-tests/functions/string/strdup.c
    pdclib-tests/functions/string/strerror.c
    pdclib-tests/functions/string/strlcat.c
    pdclib-tests/functions/string/strlcpy.c
    pdclib-tests/functions/string/strlen.c
    pdclib-tests/functions/string/strncat.c
    pdclib-tests/functions/string/strncmp.c
    pdclib-tests/functions/string/strncpy.c
    pdclib-tests/functions/string/strndup.c
    pdclib-tests/functions/string/strnlen.c
    pdclib-tests/functions/string/strpbrk.c
    pdclib-tests/functions/string/strrchr.c
    pdclib-tests/functions/string/strspn.c
    pdclib-tests/functions/string/strstr.c
    pdclib-tests/functions/string/strtok.c
    pdclib-tests/functions/string/strxfrm.c
    pdclib-tests/functions/uchar/_PDCLIB_c16slen.c
    pdclib-tests/functions/uchar/_PDCLIB_c32slen.c
    pdclib-tests/functions/uchar/_PDCLIB_c32srtombs.c
    pdclib-tests/functions/uchar/_PDCLIB_mbsrtoc32s.c
    pdclib-tests/functions/uchar/c16rtomb.c
    pdclib-tests/functions/uchar/c32rtomb.c
    pdclib-tests/functions/uchar/functions_uchar.c
    pdclib-tests/functions/uchar/mbrtoc16.c
    pdclib-tests/functions/uchar/mbrtoc32.c
    pdclib-tests/functions/wchar/functions_wchar.c
    pdclib-tests/functions/wchar/mbrtowc.c
    pdclib-tests/functions/wchar/mbsinit.c
    pdclib-tests/functions/wchar/wcrtomb.c
    pdclib-tests/functions/wchar/wcscat.c
    pdclib-tests/functions/wchar/wcschr.c
    pdclib-tests/functions/wchar/wcscmp.c
    pdclib-tests/functions/wchar/wcscpy.c
    pdclib-tests/functions/wchar/wcscspn.c
    pdclib-tests/functions/wchar/wcslen.c
    pdclib-tests/functions/wchar/wcsncat.c
    pdclib-tests/functions/wchar/wcsncmp.c
    pdclib-tests/functions/wchar/wcsncpy.c
    pdclib-tests/functions/wchar/wcspbrk.c
    pdclib-tests/functions/wchar/wcsrchr.c
    pdclib-tests/functions/wchar/wcsspn.c
    pdclib-tests/functions/wchar/wcsstr.c
    pdclib-tests/functions/wchar/wcstok.c
    pdclib-tests/functions/wchar/wmemchr.c
    pdclib-tests/functions/wchar/wmemcmp.c
    pdclib-tests/functions/wchar/wmemcpy.c
    pdclib-tests/functions/wchar/wmemmove.c
    pdclib-tests/functions/wctype/functions_wctype.c
    pdclib-tests/functions/wctype/iswalnum.c
    pdclib-tests/functions/wctype/iswalpha.c
    pdclib-tests/functions/wctype/iswblank.c
    pdclib-tests/functions/wctype/iswcntrl.c
    pdclib-tests/functions/wctype/iswctype.c
    pdclib-tests/functions/wctype/iswdigit.c
    pdclib-tests/functions/wctype/iswgraph.c
    pdclib-tests/functions/wctype/iswlower.c
    pdclib-tests/functions/wctype/iswprint.c
    pdclib-tests/functions/wctype/iswpunct.c
    pdclib-tests/functions/wctype/iswspace.c
    pdclib-tests/functions/wctype/iswupper.c
    pdclib-tests/functions/wctype/iswxdigit.c
    pdclib-tests/functions/wctype/towctrans.c
    pdclib-tests/functions/wctype/towlower.c
    pdclib-tests/functions/wctype/towupper.c
    pdclib-tests/functions/wctype/wctrans.c
    pdclib-tests/functions/wctype/wctype.c
    pdclib-tests/opt/basecodecs/_PDCLIB_ascii.c
    pdclib-tests/opt/basecodecs/_PDCLIB_latin1.c
    pdclib-tests/opt/basecodecs/_PDCLIB_utf8.c
    pdclib-tests/opt/basecodecs/opt_basecodecs.c
    pdclib-tests/opt/c_locale/_PDCLIB_initclocale.c
    pdclib-tests/opt/c_locale/opt_c_locale.c
    pdclib-tests/opt/dlmalloc/dlmalloc.c
    pdclib-tests/opt/dlmalloc/opt_dlmalloc.c
    pdclib-tests/opt/malloc-solar/calloc.c
    pdclib-tests/opt/malloc-solar/free.c
    pdclib-tests/opt/malloc-solar/malloc.c
    pdclib-tests/opt/malloc-solar/opt_malloc-solar.c
    pdclib-tests/opt/malloc-solar/realloc.c
    pdclib-tests/opt/mincoll/opt_mincoll.c
    pdclib-tests/opt/mincoll/wcscoll.c
    pdclib-tests/opt/mincoll/wcsxfrm.c
    pdclib-tests/opt/notime/opt_notime.c
    pdclib-tests/opt/notime/time.c
    pdclib-tests/opt/notime/timespec_get.c
    pdclib-tests/opt/pthreads/call_once.c
    pdclib-tests/opt/pthreads/mtx_destroy.c
    pdclib-tests/opt/pthreads/mtx_init.c
    pdclib-tests/opt/pthreads/mtx_lock.c
    pdclib-tests/opt/pthreads/mtx_timedlock.c
    pdclib-tests/opt/pthreads/mtx_trylock.c
    pdclib-tests/opt/pthreads/mtx_unlock.c
    pdclib-tests/opt/pthreads/opt_pthreads.c
    pdclib-tests/opt/pthreads/tss_create.c
    pdclib-tests/opt/pthreads/tss_delete.c
    pdclib-tests/opt/pthreads/tss_get.c
    pdclib-tests/opt/pthreads/tss_set.c
    pdclib-tests/opt/tss_errno/errno.c
    pdclib-tests/opt/tss_errno/opt_tss_errno.c
    pdclib-tests/pdclib-tests.c
)

set(PDCLIB_TESTS_SRC_SHIMMED_EXCLUDE
    pdclib-tests/functions/stdio/_cbprintf.c
    pdclib-tests/functions/stdio/_PDCLIB_filemode.c
    pdclib-tests/functions/stdio/_PDCLIB_fillbuffer.c
    pdclib-tests/functions/stdio/_PDCLIB_flushbuffer.c
    pdclib-tests/functions/stdio/_PDCLIB_ftell64.c
    pdclib-tests/functions/stdio/_PDCLIB_fvopen.c
    pdclib-tests/functions/stdio/_PDCLIB_prepread.c
    pdclib-tests/functions/stdio/_PDCLIB_prepwrite.c
    pdclib-tests/functions/stdio/_PDCLIB_print.c
    pdclib-tests/functions/stdio/_PDCLIB_scan.c
    pdclib-tests/functions/stdio/_PDCLIB_seek.c
    pdclib-tests/functions/stdio/_vcbprintf.c
    pdclib-tests/functions/stdio/clearerr.c
    pdclib-tests/functions/stdio/fclose.c
    pdclib-tests/functions/stdio/feof.c
    pdclib-tests/functions/stdio/ferror.c
    pdclib-tests/functions/stdio/fflush.c
    pdclib-tests/functions/stdio/fgetc.c
    pdclib-tests/functions/stdio/fgetpos.c
    pdclib-tests/functions/stdio/fgets.c
    pdclib-tests/functions/stdio/flockfile.c
    pdclib-tests/functions/stdio/fopen.c
    pdclib-tests/functions/stdio/fprintf.c
    pdclib-tests/functions/stdio/fputc.c
    pdclib-tests/functions/stdio/fputs.c
    pdclib-tests/functions/stdio/fread.c
    pdclib-tests/functions/stdio/freopen.c
    pdclib-tests/functions/stdio/fscanf.c
    pdclib-tests/functions/stdio/fseek.c
    pdclib-tests/functions/stdio/fsetpos.c
    pdclib-tests/functions/stdio/ftell.c
    pdclib-tests/functions/stdio/ftrylockfile.c
    pdclib-tests/functions/stdio/funlockfile.c
    pdclib-tests/functions/stdio/fwrite.c
    pdclib-tests/functions/stdio/getc.c
    pdclib-tests/functions/stdio/getchar.c
    pdclib-tests/functions/stdio/gets.c
    pdclib-tests/functions/stdio/perror.c
    pdclib-tests/functions/stdio/printf.c
    pdclib-tests/functions/stdio/putc.c
    pdclib-tests/functions/stdio/putchar.c
    pdclib-tests/functions/stdio/puts.c
    pdclib-tests/functions/stdio/rename.c
    pdclib-tests/functions/stdio/rewind.c
    pdclib-tests/functions/stdio/scanf.c
    pdclib-tests/functions/stdio/setbuf.c
    pdclib-tests/functions/stdio/setvbuf.c
    pdclib-tests/functions/stdio/snprintf.c
    pdclib-tests/functions/stdio/sprintf.c
    pdclib-tests/functions/stdio/sscanf.c
    pdclib-tests/functions/stdio/tmpnam.c
    pdclib-tests/functions/stdio/ungetc.c
    pdclib-tests/functions/stdio/vfprintf.c
    pdclib-tests/functions/stdio/vfscanf.c
    pdclib-tests/functions/stdio/vprintf.c
    pdclib-tests/functions/stdio/vscanf.c
    pdclib-tests/functions/stdio/vsnprintf.c
    pdclib-tests/functions/stdio/vsprintf.c
    pdclib-tests/functions/stdio/vsscanf.c

)

set(JIRA_REGRESSION_TESTS_SRC
    jira-regression-tests/jira-regression-tests.c
    jira-regression-tests/nsbg-2665.c
    jira-regression-tests/nsbg-3671.c
    jira-regression-tests/nsbg-3790.c
    jira-regression-tests/rynda-183.c
    jira-regression-tests/rynda-249.c
    jira-regression-tests/rynda-293.c
    jira-regression-tests/rynda-492.c
    jira-regression-tests/rynda-525.c
    jira-regression-tests/rynda-579.c
    jira-regression-tests/siglontd-1043.c
    jira-regression-tests/siglontd-2074.c
)

#    ntd-tests/functions/stdlib/malloc-test-helpers/malloc_test_helper_funcs.c
#    ntd-tests/functions/stdlib/malloc-test-helpers/test_OSMemoryHeap.cpp
#    ntd-tests/functions/stdlib/malloc-test-helpers/test_WalkFreeList.c
#    ntd-tests/functions/stdlib/malloc-test-helpers/test_MiscTests.c
#    ntd-tests/functions/stdlib/malloc_tests.c

set(NTD_TEST_SRC
    ntd-tests/ntd-tests.c
    ntd-tests/functions/dirent/ntd_functions_dirent.c
    ntd-tests/functions/dirent/bug-readdir1.c
    ntd-tests/functions/dirent/dirent_list.c
    ntd-tests/functions/dirent/tst-seekdir.c
    ntd-tests/functions/string/ntd_functions_string.c
    ntd-tests/functions/string/fnmatch.c
    ntd-tests/functions/string/ntd-test-memcpy.c
    ntd-tests/functions/string/ntd-test-memccpy.c
    ntd-tests/functions/stdlib/ntd_functions_stdlib.c
    ntd-tests/functions/stdio/ntd_functions_stdio.c
    ntd-tests/functions/stdio/ntd_stdio_clearerr.c
    ntd-tests/functions/stdio/ntd_stdio_fgetpos.c
    ntd-tests/functions/stdio/ntd_stdio_fgets.c
    ntd-tests/functions/stdio/ntd_stdio_fprintf.c
    ntd-tests/functions/stdio/ntd_stdio_fputs.c
    ntd-tests/functions/stdio/ntd_stdio_fread.c
    ntd-tests/functions/stdio/ntd_stdio_freopen.c
    ntd-tests/functions/stdio/ntd_stdio_fscanf.c
    ntd-tests/functions/stdio/ntd_stdio_fseek.c
    ntd-tests/functions/stdio/ntd_stdio_ftell.c
    ntd-tests/functions/stdio/ntd_stdio_snprintf.c
    ntd-tests/functions/stdio/ntd_stdio_sprintf.c
    ntd-tests/functions/stdio/ntd_stdio_sscanf.c
    ntd-tests/functions/stdio/ntd_stdio_ungetc.c
    ntd-tests/functions/stdio/ntd_stdio_vfprintf.c
    ntd-tests/functions/stdio/ntd_stdio_vfscanf.c
    ntd-tests/functions/stdio/ntd_stdio_vsnprintf.c
    ntd-tests/functions/stdio/ntd_stdio_vsprintf.c
    ntd-tests/functions/stdio/ntd_stdio_vsscanf.c
    ntd-tests/functions/stdio/ntd_stdio_rename.c

   ntd-tests/functions/threads/ntd_functions_threads.c

   ntd-tests/functions/threads/test_pthread_affinity.c
   ntd-tests/functions/threads/test_pthread_attr_set_and_get.c
   ntd-tests/functions/threads/test_pthread_attr_setinheritsched.c
   ntd-tests/functions/threads/test_pthread_attr_setschedparam_1.c
   ntd-tests/functions/threads/test_pthread_attr_setschedparam_2.c
   ntd-tests/functions/threads/test_pthread_attr_setschedpolicy.c
   ntd-tests/functions/threads/test_pthread_attr_setscope.c
#   ntd-tests/functions/threads/test_pthread_attr_setstack.cpp
   ntd-tests/functions/threads/test_pthread_barrier.c
   ntd-tests/functions/threads/test_pthread_cond_broadcast.c
   ntd-tests/functions/threads/test_pthread_cond_destroy.c
   ntd-tests/functions/threads/test_pthread_cond_init.c
   ntd-tests/functions/threads/test_pthread_cond_signal.c
   ntd-tests/functions/threads/test_pthread_cond_timedwait.c
   ntd-tests/functions/threads/test_pthread_cond_wait.c
   ntd-tests/functions/threads/test_pthread_condattr_setpshared.c
   ntd-tests/functions/threads/test_pthread_errno_locale.c
   ntd-tests/functions/threads/test_pthread_getschedparam.c
   ntd-tests/functions/threads/test_pthread_getspecific.c
   ntd-tests/functions/threads/test_pthread_join.c
   ntd-tests/functions/threads/test_pthread_key_create.c
   ntd-tests/functions/threads/test_pthread_key_delete.c
   ntd-tests/functions/threads/test_pthread_mutex_destroy.c
   ntd-tests/functions/threads/test_pthread_mutex_init.c
   ntd-tests/functions/threads/test_pthread_mutex_lock.c
   ntd-tests/functions/threads/test_pthread_mutex_trylock.c
   ntd-tests/functions/threads/test_pthread_mutex_trylock_yield.c
   ntd-tests/functions/threads/test_pthread_mutex_unlock.c
   ntd-tests/functions/threads/test_pthread_mutexattr_settype.c
   ntd-tests/functions/threads/test_pthread_once.c
   ntd-tests/functions/threads/test_pthread_setname_np.c
   ntd-tests/functions/threads/test_pthread_setspecific.c
   ntd-tests/functions/threads/test_pthread_validate_filelocks.c
   ntd-tests/functions/threads/test_sched_get_priority_max.c
   ntd-tests/functions/threads/test_sched_yield.c
   ntd-tests/functions/threads/test_sem_destroy.c
   ntd-tests/functions/threads/test_sem_getvalue.c
   ntd-tests/functions/threads/test_sem_post.c
   ntd-tests/functions/threads/test_sem_timedwait.c
   ntd-tests/functions/threads/test_sem_trywait.c
   ntd-tests/functions/threads/test_sem_wait.c

   ntd-tests/functions/unistd/ftruncate.c
   ntd-tests/functions/unistd/ntd_functions_unistd.c

#  ntd-tests/extended/ntd_extended_atexit.c
#  ntd-tests/extended/ntd_extended_clock.c
   ntd-tests/extended/ntd_extended_fopen.c
   ntd-tests/extended/ntd_extended_freopen.c
   ntd-tests/extended/ntd_extended_fwrite.c
#  ntd-tests/extended/ntd_extended_malloc.c
   ntd-tests/extended/ntd_extended_memstream.c
   ntd-tests/extended/ntd_extended_pread.c
#  ntd-tests/extended/ntd_extended_perror.c
   ntd-tests/extended/ntd_extended_realloc.c
   ntd-tests/extended/ntd_extended_remove.c
   ntd-tests/extended/ntd_extended_rename.c
   ntd-tests/extended/ntd_extended_rewind.c
   ntd-tests/extended/ntd_extended_tests.c
   ntd-tests/extended/ntd_extended_time.c
#  ntd-tests/extended/ntd_extended_tmpnam.c
   ntd-tests/extended/ntd_extended_leak.c
   ntd-tests/extended/ntd_extended_chdir.c
   )

# EXCLUDED musl-libc-tests
#       musl-libc-tests/test__functional/testdlopen.c
#       musl-libc-tests/test__functional/testdlopen_dso.c
#       musl-libc-tests/test__functional/testfcntl.c
#       musl-libc-tests/test__functional/testfdopen.c
#       musl-libc-tests/test__functional/testinet_pton.c
#       musl-libc-tests/test__functional/testipc_msg.c
#       musl-libc-tests/test__functional/testipc_sem.c
#       musl-libc-tests/test__functional/testipc_shm.c
#       musl-libc-tests/test__functional/testmbc.c
#       musl-libc-tests/test__functional/testpopen.c
#       musl-libc-tests/test__functional/testpthread_cancel-points.c
#       musl-libc-tests/test__functional/testpthread_cancel.c
#       musl-libc-tests/test__functional/testpthread_cond.c
#       musl-libc-tests/test__functional/testpthread_mutex.c
#       musl-libc-tests/test__functional/testsem_init.c
#       musl-libc-tests/test__functional/testsem_open.c
#       musl-libc-tests/test__functional/testsocket.c
#       musl-libc-tests/test__functional/testspawn.c
#       musl-libc-tests/test__functional/testsscanf_long.c
#       musl-libc-tests/test__functional/teststat.c
#       musl-libc-tests/test__functional/testtls_align.c
#       musl-libc-tests/test__functional/testtls_align_dlopen.c
#       musl-libc-tests/test__functional/testtls_align_dso.c
#       musl-libc-tests/test__functional/testtls_init.c
#       musl-libc-tests/test__functional/testtls_init_dlopen.c
#       musl-libc-tests/test__functional/testtls_init_dso.c
#       musl-libc-tests/test__functional/testvfork.c
#       musl-libc-tests/test__regression/testdaemon-failure.c
#       musl-libc-tests/test__regression/testdn_expand-empty.c
#       musl-libc-tests/test__regression/testdn_expand-ptr-0.c
#       musl-libc-tests/test__regression/testfflush-exit.c
#       musl-libc-tests/test__regression/testftello-unflushed-append.c
#       musl-libc-tests/test__regression/testinet_ntop-v4mapped.c
#       musl-libc-tests/test__regression/testmalloc-brk-fail.c
#       musl-libc-tests/test__regression/testpthread_cancel-sem_wait.c
#       musl-libc-tests/test__regression/testpthread_exit-dtor.c
#       musl-libc-tests/test__regression/testpthread_once-deadlock.c
#       musl-libc-tests/test__regression/testraise-race.c
#       musl-libc-tests/test__regression/testrlimit-open-files.c
#       musl-libc-tests/test__regression/testsetenv-oom.c
#       musl-libc-tests/test__regression/teststatvfs.c
#       musl-libc-tests/test__regression/testsyscall-sign-extend.c

#			musl-libc-tests/test__functional/testargv.c
#			musl-libc-tests/test__regression/testmalloc-oom.c
#			musl-libc-tests/test__regression/testsigaltstack.c
#			musl-libc-tests/test__regression/testsigprocmask-internal.c
#			musl-libc-tests/test__regression/testsigreturn.c
#     musl-libc-tests/test__regression/testpthread_cond-smasher.c
#     musl-libc-tests/test__regression/testpthread_condattr_setclock.c

# 	  musl-libc-tests/test__functional/testfscanf.c	can't run uses pipe
#			musl-libc-tests/test__functional/testfwscanf.c
#			musl-libc-tests/test__functional/testungetc.c
#			musl-libc-tests/test__functional/testpthread_robust.c
#    	musl-libc-tests/test__functional/testtime__functional.c
#    	musl-libc-tests/test__regression/testexecle-env.c
#    	musl-libc-tests/test__regression/testfgets-eof.c
#    	musl-libc-tests/test__regression/testflockfile-list.c
#     musl-libc-tests/test__regression/testmkdtemp-failure.c
#     musl-libc-tests/test__regression/testmkstemp-failure.c
#    	musl-libc-tests/test__regression/testpthread_create-oom.c
#     musl-libc-tests/test__regression/testpthread_rwlock-ebusy.c
#    	musl-libc-tests/test__regression/testrewind-clear-error.c
#     musl-libc-tests/test__regression/testpthread_exit-cancel.c

set(MUSL_LIBC_TESTS_SRC
    musl-libc-tests/musl-libc-tests.c
    musl-libc-tests/replacement--test.c
    musl-libc-tests/musl-libc-test/common/mtest.c
    musl-libc-tests/musl-libc-test/common/path.c
    musl-libc-tests/musl-libc-test/common/print.c
    musl-libc-tests/musl-libc-test/common/rand.c
    musl-libc-tests/test__functional/testbasename.c
    musl-libc-tests/test__functional/testclock_gettime.c
    musl-libc-tests/test__functional/testcrypt.c
    musl-libc-tests/test__functional/testdirname.c
    musl-libc-tests/test__functional/testenv.c
    musl-libc-tests/test__functional/testfnmatch.c
    musl-libc-tests/test__functional/testiconv_open.c
    musl-libc-tests/test__functional/testmbc.c
    musl-libc-tests/test__functional/testmemstream.c
    musl-libc-tests/test__functional/testpthread_cond.c
    musl-libc-tests/test__functional/testpthread_mutex.c
    musl-libc-tests/test__functional/testpthread_tsd.c
    musl-libc-tests/test__functional/testqsort.c
    musl-libc-tests/test__functional/testrandom.c
    musl-libc-tests/test__functional/testsearch_hsearch.c
    musl-libc-tests/test__functional/testsearch_insque.c
    musl-libc-tests/test__functional/testsearch_lsearch.c
    musl-libc-tests/test__functional/testsearch_tsearch.c
    musl-libc-tests/test__functional/testsetjmp.c
    musl-libc-tests/test__functional/testsnprintf.c
    musl-libc-tests/test__functional/testsscanf.c
    musl-libc-tests/test__functional/teststring.c
    musl-libc-tests/test__functional/teststring_memcpy.c
    musl-libc-tests/test__functional/teststring_memmem.c
    musl-libc-tests/test__functional/teststring_memset.c
    musl-libc-tests/test__functional/teststring_strchr.c
    musl-libc-tests/test__functional/teststring_strcspn.c
    musl-libc-tests/test__functional/teststring_strstr.c
    musl-libc-tests/test__functional/teststrtod.c
    musl-libc-tests/test__functional/teststrtod_long.c
    musl-libc-tests/test__functional/teststrtod_simple.c
    musl-libc-tests/test__functional/teststrtof.c
    musl-libc-tests/test__functional/teststrtol.c
    musl-libc-tests/test__functional/teststrtold.c
    musl-libc-tests/test__functional/testswprintf.c
    musl-libc-tests/test__functional/testtgmath.c
    musl-libc-tests/test__functional/testudiv.c
    musl-libc-tests/test__functional/testwcsstr.c
    musl-libc-tests/test__functional/testwcstol.c
    musl-libc-tests/test__functional/testungetc.c
    musl-libc-tests/test__functional/musl_libc_test__functional__run.c
    musl-libc-tests/test__math/testacos.c
    musl-libc-tests/test__math/testacosf.c
    musl-libc-tests/test__math/testacosh.c
    musl-libc-tests/test__math/testacoshf.c
    musl-libc-tests/test__math/testacoshl.c
    musl-libc-tests/test__math/testacosl.c
    musl-libc-tests/test__math/testasin.c
    musl-libc-tests/test__math/testasinf.c
    musl-libc-tests/test__math/testasinh.c
    musl-libc-tests/test__math/testasinhf.c
    musl-libc-tests/test__math/testasinhl.c
    musl-libc-tests/test__math/testasinl.c
    musl-libc-tests/test__math/testatan.c
    musl-libc-tests/test__math/testatan2.c
    musl-libc-tests/test__math/testatan2f.c
    musl-libc-tests/test__math/testatan2l.c
    musl-libc-tests/test__math/testatanf.c
    musl-libc-tests/test__math/testatanh.c
    musl-libc-tests/test__math/testatanhf.c
    musl-libc-tests/test__math/testatanhl.c
    musl-libc-tests/test__math/testatanl.c
    musl-libc-tests/test__math/testcbrt.c
    musl-libc-tests/test__math/testcbrtf.c
    musl-libc-tests/test__math/testcbrtl.c
    musl-libc-tests/test__math/testceil.c
    musl-libc-tests/test__math/testceilf.c
    musl-libc-tests/test__math/testceill.c
    musl-libc-tests/test__math/testcopysign.c
    musl-libc-tests/test__math/testcopysignf.c
    musl-libc-tests/test__math/testcopysignl.c
    musl-libc-tests/test__math/testcos.c
    musl-libc-tests/test__math/testcosf.c
    musl-libc-tests/test__math/testcosh.c
    musl-libc-tests/test__math/testcoshf.c
    musl-libc-tests/test__math/testcoshl.c
    musl-libc-tests/test__math/testcosl.c
    musl-libc-tests/test__math/testdrem.c
    musl-libc-tests/test__math/testdremf.c
    musl-libc-tests/test__math/testerf.c
    musl-libc-tests/test__math/testerfc.c
    musl-libc-tests/test__math/testerfcf.c
    musl-libc-tests/test__math/testerfcl.c
    musl-libc-tests/test__math/testerff.c
    musl-libc-tests/test__math/testerfl.c
    musl-libc-tests/test__math/testexp.c
    musl-libc-tests/test__math/testexp10.c
    musl-libc-tests/test__math/testexp10f.c
    musl-libc-tests/test__math/testexp10l.c
    musl-libc-tests/test__math/testexp2.c
    musl-libc-tests/test__math/testexp2f.c
    musl-libc-tests/test__math/testexp2l.c
    musl-libc-tests/test__math/testexpf.c
    musl-libc-tests/test__math/testexpl.c
    musl-libc-tests/test__math/testexpm1.c
    musl-libc-tests/test__math/testexpm1f.c
    musl-libc-tests/test__math/testexpm1l.c
    musl-libc-tests/test__math/testfabs.c
    musl-libc-tests/test__math/testfabsf.c
    musl-libc-tests/test__math/testfabsl.c
    musl-libc-tests/test__math/testfdim.c
    musl-libc-tests/test__math/testfdimf.c
    musl-libc-tests/test__math/testfdiml.c
    musl-libc-tests/test__math/testfenv.c
    musl-libc-tests/test__math/testfloor.c
    musl-libc-tests/test__math/testfloorf.c
    musl-libc-tests/test__math/testfloorl.c
    musl-libc-tests/test__math/testfma.c
    musl-libc-tests/test__math/testfmaf.c
    musl-libc-tests/test__math/testfmal.c
    musl-libc-tests/test__math/testfmax.c
    musl-libc-tests/test__math/testfmaxf.c
    musl-libc-tests/test__math/testfmaxl.c
    musl-libc-tests/test__math/testfmin.c
    musl-libc-tests/test__math/testfminf.c
    musl-libc-tests/test__math/testfminl.c
    musl-libc-tests/test__math/testfmod.c
    musl-libc-tests/test__math/testfmodf.c
    musl-libc-tests/test__math/testfmodl.c
    musl-libc-tests/test__math/testfpclassify.c
    musl-libc-tests/test__math/testfrexp.c
    musl-libc-tests/test__math/testfrexpf.c
    musl-libc-tests/test__math/testfrexpl.c
    musl-libc-tests/test__math/testhypot.c
    musl-libc-tests/test__math/testhypotf.c
    musl-libc-tests/test__math/testhypotl.c
    musl-libc-tests/test__math/testilogb.c
    musl-libc-tests/test__math/testilogbf.c
    musl-libc-tests/test__math/testilogbl.c
    musl-libc-tests/test__math/testisless.c
    musl-libc-tests/test__math/testj0.c
    musl-libc-tests/test__math/testj0f.c
    musl-libc-tests/test__math/testj1.c
    musl-libc-tests/test__math/testj1f.c
    musl-libc-tests/test__math/testjn.c
    musl-libc-tests/test__math/testjnf.c
    musl-libc-tests/test__math/testldexp.c
    musl-libc-tests/test__math/testldexpf.c
    musl-libc-tests/test__math/testldexpl.c
    musl-libc-tests/test__math/testlgamma.c
    musl-libc-tests/test__math/testlgamma_r.c
    musl-libc-tests/test__math/testlgammaf.c
    musl-libc-tests/test__math/testlgammaf_r.c
    musl-libc-tests/test__math/testlgammal.c
    musl-libc-tests/test__math/testlgammal_r.c
    musl-libc-tests/test__math/testllrint.c
    musl-libc-tests/test__math/testllrintf.c
    musl-libc-tests/test__math/testllrintl.c
    musl-libc-tests/test__math/testllround.c
    musl-libc-tests/test__math/testllroundf.c
    musl-libc-tests/test__math/testllroundl.c
    musl-libc-tests/test__math/testlog.c
    musl-libc-tests/test__math/testlog10.c
    musl-libc-tests/test__math/testlog10f.c
    musl-libc-tests/test__math/testlog10l.c
    musl-libc-tests/test__math/testlog1p.c
    musl-libc-tests/test__math/testlog1pf.c
    musl-libc-tests/test__math/testlog1pl.c
    musl-libc-tests/test__math/testlog2.c
    musl-libc-tests/test__math/testlog2f.c
    musl-libc-tests/test__math/testlog2l.c
    musl-libc-tests/test__math/testlogb.c
    musl-libc-tests/test__math/testlogbf.c
    musl-libc-tests/test__math/testlogbl.c
    musl-libc-tests/test__math/testlogf.c
    musl-libc-tests/test__math/testlogl.c
    musl-libc-tests/test__math/testlrint.c
    musl-libc-tests/test__math/testlrintf.c
    musl-libc-tests/test__math/testlrintl.c
    musl-libc-tests/test__math/testlround.c
    musl-libc-tests/test__math/testlroundf.c
    musl-libc-tests/test__math/testlroundl.c
    musl-libc-tests/test__math/testmodf.c
    musl-libc-tests/test__math/testmodff.c
    musl-libc-tests/test__math/testmodfl.c
    musl-libc-tests/test__math/testnearbyint.c
    musl-libc-tests/test__math/testnearbyintf.c
    musl-libc-tests/test__math/testnearbyintl.c
    musl-libc-tests/test__math/testnextafter.c
    musl-libc-tests/test__math/testnextafterf.c
    musl-libc-tests/test__math/testnextafterl.c
    musl-libc-tests/test__math/testnexttoward.c
    musl-libc-tests/test__math/testnexttowardf.c
    musl-libc-tests/test__math/testnexttowardl.c
    musl-libc-tests/test__math/testpow.c
    musl-libc-tests/test__math/testpow10.c
    musl-libc-tests/test__math/testpow10f.c
    musl-libc-tests/test__math/testpow10l.c
    musl-libc-tests/test__math/testpowf.c
    musl-libc-tests/test__math/testpowl.c
    musl-libc-tests/test__math/testremainder.c
    musl-libc-tests/test__math/testremainderf.c
    musl-libc-tests/test__math/testremainderl.c
    musl-libc-tests/test__math/testremquo.c
    musl-libc-tests/test__math/testremquof.c
    musl-libc-tests/test__math/testremquol.c
    musl-libc-tests/test__math/testrint.c
    musl-libc-tests/test__math/testrintf.c
    musl-libc-tests/test__math/testrintl.c
    musl-libc-tests/test__math/testround.c
    musl-libc-tests/test__math/testroundf.c
    musl-libc-tests/test__math/testroundl.c
    musl-libc-tests/test__math/testscalb.c
    musl-libc-tests/test__math/testscalbf.c
    musl-libc-tests/test__math/testscalbln.c
    musl-libc-tests/test__math/testscalblnf.c
    musl-libc-tests/test__math/testscalblnl.c
    musl-libc-tests/test__math/testscalbn.c
    musl-libc-tests/test__math/testscalbnf.c
    musl-libc-tests/test__math/testscalbnl.c
    musl-libc-tests/test__math/testsin.c
    musl-libc-tests/test__math/testsincos.c
    musl-libc-tests/test__math/testsincosf.c
    musl-libc-tests/test__math/testsincosl.c
    musl-libc-tests/test__math/testsinf.c
    musl-libc-tests/test__math/testsinh.c
    musl-libc-tests/test__math/testsinhf.c
    musl-libc-tests/test__math/testsinhl.c
    musl-libc-tests/test__math/testsinl.c
    musl-libc-tests/test__math/testsqrt.c
    musl-libc-tests/test__math/testsqrtf.c
    musl-libc-tests/test__math/testsqrtl.c
    musl-libc-tests/test__math/testtan.c
    musl-libc-tests/test__math/testtanf.c
    musl-libc-tests/test__math/testtanh.c
    musl-libc-tests/test__math/testtanhf.c
    musl-libc-tests/test__math/testtanhl.c
    musl-libc-tests/test__math/testtanl.c
    musl-libc-tests/test__math/testtgamma.c
    musl-libc-tests/test__math/testtgammaf.c
    musl-libc-tests/test__math/testtgammal.c
    musl-libc-tests/test__math/testtrunc.c
    musl-libc-tests/test__math/testtruncf.c
    musl-libc-tests/test__math/testtruncl.c
    musl-libc-tests/test__math/testy0.c
    musl-libc-tests/test__math/testy0f.c
    musl-libc-tests/test__math/testy1.c
    musl-libc-tests/test__math/testy1f.c
    musl-libc-tests/test__math/testyn.c
    musl-libc-tests/test__math/testynf.c
    musl-libc-tests/test__math/musl_libc_test__math__run.c
    musl-libc-tests/test__musl/testpleval.c
    musl-libc-tests/test__musl/musl_libc_test__musl__run.c
    musl-libc-tests/test__regression/testfpclassify-invalid-ld80.c
    musl-libc-tests/test__regression/testiswspace-null.c
    musl-libc-tests/test__regression/testlrand48-signextend.c
    musl-libc-tests/test__regression/testmalloc-0.c
    musl-libc-tests/test__regression/testmbsrtowcs-overflow.c
    musl-libc-tests/test__regression/testmemmem-oob-read.c
    musl-libc-tests/test__regression/testmemmem-oob.c
    musl-libc-tests/test__regression/testprintf-1e9-oob.c
    musl-libc-tests/test__regression/testprintf-fmt-g-round.c
    musl-libc-tests/test__regression/testprintf-fmt-g-zeros.c
    musl-libc-tests/test__regression/testprintf-fmt-n.c
    musl-libc-tests/test__regression/testregex-negated-range.c
    musl-libc-tests/test__regression/testregexec-nosub.c
    musl-libc-tests/test__regression/testscanf-bytes-consumed.c
    musl-libc-tests/test__regression/testscanf-match-literal-eof.c
    musl-libc-tests/test__regression/testscanf-nullbyte-char.c
    musl-libc-tests/test__regression/testwcsncpy-read-overflow.c
    musl-libc-tests/test__regression/testwcsstr-false-negative.c
    musl-libc-tests/test__regression/musl_libc_test__regression__run.c
)
include_directories(
	.
	pdclib-tests
	musl-libc-tests/musl-libc-test/common
	${CURRENT_SDK_TARGET_LIB}/../include
	)

PRINT_VARIABLE(NATIVE_MUSL)
PRINT_VARIABLE(CMAKE_HOST_SYSTEM_NAME)
if ("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Windows")
    message(STATUS "setting CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS to 1")
    set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
endif()

add_executable(ntd_test_libc
    ${NTD_TEST_LIBC_DRIVER_SRC}
    ${PDCLIB_TESTS_SRC}
    ${JIRA_REGRESSION_TESTS_SRC}
    ${NTD_TEST_SRC}
    ${MUSL_LIBC_TESTS_SRC}
)

list(APPEND COMPILE_FLAGS "-std=c11")
list(APPEND COMPILE_FLAGS "-Wno-format")
list(APPEND COMPILE_FLAGS "-gdwarf-2")
list(APPEND COMPILE_FLAGS "-Wno-literal-range")
list(APPEND COMPILE_FLAGS "-Wno-unknown-pragmas")
list(APPEND COMPILE_FLAGS "-Wno-tautological-constant-out-of-range-compare")
list(APPEND COMPILE_FLAGS "-Wno-incompatible-pointer-types-discards-qualifiers")
list(APPEND COMPILE_FLAGS "-O0")
# test our functions not the compiler.
list(APPEND COMPILE_FLAGS "-fno-builtin")

list(APPEND LINK_FLAGS -Wl,-Map=map_file.map)
# list(APPEND LINK_FLAGS -v)

macro_list_to_flags(COMPILE_FLAGS COMPILE_FLAGS)
macro_list_to_flags(LINK_FLAGS LINK_FLAGS)

set_target_properties(ntd_test_libc
  PROPERTIES
  	COMPILE_FLAGS "${COMPILE_FLAGS}"
    LINK_FLAGS    "${LINK_FLAGS}"
    OUTPUT_NAME   "ntd-test-libc"
  )
