https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8c4aff39a891f67cac045eff9a02f93a150663fe

commit 8c4aff39a891f67cac045eff9a02f93a150663fe
Author:     Timo Kreuzer <[email protected]>
AuthorDate: Sat Jul 17 14:53:17 2021 +0200
Commit:     Timo Kreuzer <[email protected]>
CommitDate: Tue Jul 20 23:13:03 2021 +0200

    [CRT] Refactor CMake files
---
 sdk/lib/crt/CMakeLists.txt          |  74 ++---
 sdk/lib/crt/conio/conio.cmake       |  10 +
 sdk/lib/crt/crt.cmake               | 627 ++----------------------------------
 sdk/lib/crt/direct/direct.cmake     |  16 +
 sdk/lib/crt/except/except.cmake     |  85 +++++
 sdk/lib/crt/float/float.cmake       |  42 +++
 sdk/lib/crt/libcntpr.cmake          | 255 ++-------------
 sdk/lib/crt/math/math.cmake         | 189 +++++++++++
 sdk/lib/crt/mbstring/mbstring.cmake |  63 ++++
 sdk/lib/crt/mem/mem.cmake           |  32 ++
 sdk/lib/crt/misc/misc.cmake         |  29 ++
 sdk/lib/crt/printf/printf.cmake     |  50 +++
 sdk/lib/crt/process/process.cmake   |  12 +
 sdk/lib/crt/search/search.cmake     |  10 +
 sdk/lib/crt/setjmp/setjmp.cmake     |  18 ++
 sdk/lib/crt/startup/startup.cmake   |  29 ++
 sdk/lib/crt/stdio/stdio.cmake       |  22 ++
 sdk/lib/crt/stdlib/stdlib.cmake     |  49 +++
 sdk/lib/crt/string/string.cmake     | 128 ++++++++
 sdk/lib/crt/time/time.cmake         |  41 +++
 sdk/lib/crt/wine/wine.cmake         |  26 ++
 sdk/lib/crt/wstring/wstring.cmake   |  17 +
 22 files changed, 937 insertions(+), 887 deletions(-)

diff --git a/sdk/lib/crt/CMakeLists.txt b/sdk/lib/crt/CMakeLists.txt
index 24d4205fbd0..3ade9c84877 100644
--- a/sdk/lib/crt/CMakeLists.txt
+++ b/sdk/lib/crt/CMakeLists.txt
@@ -1,28 +1,28 @@
 
 include_directories(include)
+#include_directories(.)
 
 add_definitions(-D_CRTBLD)
 
-if(ARCH STREQUAL "i386")
-    list(APPEND CHKSTK_ASM_SOURCE except/i386/chkstk_asm.s)
-    if(NOT MSVC)
-        list(APPEND CHKSTK_SOURCE except/i386/chkstk_ms.s)
-    endif()
-elseif(ARCH STREQUAL "amd64")
-    list(APPEND CHKSTK_ASM_SOURCE except/amd64/chkstk_ms.s)
-elseif(ARCH STREQUAL "arm")
-    list(APPEND CHKSTK_ASM_SOURCE except/arm/chkstk_asm.s)
-    if(NOT MSVC)
-        list(APPEND CHKSTK_SOURCE except/arm/chkstk_ms.s)
-    endif()
-elseif(ARCH STREQUAL "powerpc")
-    list(APPEND CHKSTK_ASM_SOURCE except/powerpc/chkstk_asm.s)
-endif()
-
-add_asm_files(chkstk_lib_asm ${CHKSTK_ASM_SOURCE})
-add_library(chkstk ${CHKSTK_SOURCE} ${chkstk_lib_asm})
-set_target_properties(chkstk PROPERTIES LINKER_LANGUAGE "C")
-add_dependencies(chkstk asm)
+include(conio/conio.cmake)
+include(direct/direct.cmake)
+include(except/except.cmake)
+include(float/float.cmake)
+include(math/math.cmake)
+include(mbstring/mbstring.cmake)
+include(mem/mem.cmake)
+include(misc/misc.cmake)
+include(printf/printf.cmake)
+include(process/process.cmake)
+include(search/search.cmake)
+include(setjmp/setjmp.cmake)
+include(startup/startup.cmake)
+include(stdio/stdio.cmake)
+include(stdlib/stdlib.cmake)
+include(string/string.cmake)
+include(time/time.cmake)
+include(wine/wine.cmake)
+include(wstring/wstring.cmake)
 
 include(crt.cmake)
 include(libcntpr.cmake)
@@ -45,37 +45,3 @@ add_library(user32_wsprintf
 
 add_dependencies(user32_wsprintf psdk)
 target_compile_definitions(user32_wsprintf PRIVATE _USER32_WSPRINTF)
-
-add_library(memcmp mem/memcmp.c)
-add_dependencies(memcmp psdk)
-
-add_library(getopt misc/getopt.c)
-target_compile_definitions(getopt PRIVATE _DLL __USE_CRTIMP)
-add_dependencies(getopt psdk)
-
-add_library(strtol
-    string/ctype.c
-    string/iswctype.c
-    string/strtoi64.c
-    string/strtol.c
-    string/strtoul.c
-    string/strtoull.c
-    string/wctype.c)
-target_compile_definitions(strtol PRIVATE _LIBCNT_)
-add_dependencies(strtol psdk)
-
-
-if(ARCH STREQUAL "i386")
-    list(APPEND ATAN2_ASM_SOURCE math/i386/atan2_asm.s)
-elseif(ARCH STREQUAL "amd64")
-    list(APPEND ATAN2_ASM_SOURCE math/amd64/atan2.S)
-elseif(ARCH STREQUAL "arm")
-    list(APPEND ATAN2_ASM_SOURCE math/arm/atan2.s)
-endif()
-
-add_asm_files(atan2_asm ${ATAN2_ASM_SOURCE})
-add_library(atan2 ${atan2_asm})
-set_target_properties(atan2 PROPERTIES LINKER_LANGUAGE "C")
-add_dependencies(atan2 asm)
-
-
diff --git a/sdk/lib/crt/conio/conio.cmake b/sdk/lib/crt/conio/conio.cmake
new file mode 100644
index 00000000000..1a5aafb7fdb
--- /dev/null
+++ b/sdk/lib/crt/conio/conio.cmake
@@ -0,0 +1,10 @@
+
+list(APPEND CRT_CONIO_SOURCE
+    conio/cgets.c
+    conio/cputs.c
+    conio/getch.c
+    conio/getche.c
+    conio/kbhit.c
+    conio/putch.c
+    conio/ungetch.c   
+)
diff --git a/sdk/lib/crt/crt.cmake b/sdk/lib/crt/crt.cmake
index f3b9160a9b5..91f9d4a074e 100644
--- a/sdk/lib/crt/crt.cmake
+++ b/sdk/lib/crt/crt.cmake
@@ -1,611 +1,42 @@
 
 list(APPEND CRT_SOURCE
-    conio/cgets.c
-    conio/cputs.c
-    conio/getch.c
-    conio/getche.c
-    conio/kbhit.c
-    conio/putch.c
-    conio/ungetch.c
-    direct/chdir.c
-    direct/chdrive.c
-    direct/getcwd.c
-    direct/getdcwd.c
-    direct/getdfree.c
-    direct/getdrive.c
-    direct/mkdir.c
-    direct/rmdir.c
-    direct/wchdir.c
-    direct/wgetcwd.c
-    direct/wgetdcwd.c
-    direct/wmkdir.c
-    direct/wrmdir.c
-    except/matherr.c
-    except/stack.c
-    float/chgsign.c
-    float/copysign.c
-    float/fpclass.c
-    float/fpecode.c
-    float/isnan.c
-    float/nafter.c
-    float/scalb.c
+    ${CRT_CONIO_SOURCE}
+    ${CRT_DIRECT_SOURCE}
+    ${CRT_EXCEPT_SOURCE}
+    ${CRT_FLOAT_SOURCE}
     locale/locale.c
-    math/abs.c
-    math/acos.c
-    math/adjust.c
-    math/asin.c
-    math/cabs.c
-    math/cosf.c
-    math/cosh.c
-    math/div.c
-    math/fdivbug.c
-    math/frexp.c
-    math/huge_val.c
-    math/hypot.c
-    math/ieee754/j0_y0.c
-    math/ieee754/j1_y1.c
-    math/ieee754/jn_yn.c
-    math/j0_y0.c
-    math/j1_y1.c
-    math/jn_yn.c
-    math/labs.c
-    math/ldiv.c
-    math/logf.c
-    math/modf.c
-    math/powf.c
-    math/rand.c
-    math/s_modf.c
-    math/sinf.c
-    math/sinh.c
-    math/tanh.c
-    mbstring/_setmbcp.c
-    mbstring/hanzen.c
-    mbstring/ischira.c
-    mbstring/iskana.c
-    mbstring/iskmoji.c
-    mbstring/iskpun.c
-    mbstring/islead.c
-    mbstring/islwr.c
-    mbstring/ismbal.c
-    mbstring/ismbaln.c
-    mbstring/ismbc.c
-    mbstring/ismbgra.c
-    mbstring/ismbkaln.c
-    mbstring/ismblead.c
-    mbstring/ismbpri.c
-    mbstring/ismbpun.c
-    mbstring/ismbtrl.c
-    mbstring/isuppr.c
-    mbstring/jistojms.c
-    mbstring/jmstojis.c
-    mbstring/mbbtype.c
-    mbstring/mbccpy.c
-    mbstring/mbclen.c
-    mbstring/mbscat.c
-    mbstring/mbschr.c
-    mbstring/mbscmp.c
-    mbstring/mbscoll.c
-    mbstring/mbscpy.c
-    mbstring/mbscspn.c
-    mbstring/mbsdec.c
-    mbstring/mbsdup.c
-    mbstring/mbsicmp.c
-    mbstring/mbsicoll.c
-    mbstring/mbsinc.c
-    mbstring/mbslen.c
-    mbstring/mbslwr.c
-    mbstring/mbsncat.c
-    mbstring/mbsnccnt.c
-    mbstring/mbsncmp.c
-    mbstring/mbsncoll.c
-    mbstring/mbsncpy.c
-    mbstring/mbsnextc.c
-    mbstring/mbsnicmp.c
-    mbstring/mbsnicoll.c
-    mbstring/mbsninc.c
-    mbstring/mbsnset.c
-    mbstring/mbspbrk.c
-    mbstring/mbsrchr.c
-    mbstring/mbsrev.c
-    mbstring/mbsset.c
-    mbstring/mbsspn.c
-    mbstring/mbsspnp.c
-    mbstring/mbsstr.c
-    mbstring/mbstok.c
-    mbstring/mbstrlen.c
-    mbstring/mbsupr.c
-    mem/memcmp.c
-    mem/memccpy.c
-    mem/memicmp.c
-    misc/__crt_MessageBoxA.c
-    misc/amsg.c
-    misc/assert.c
-    misc/environ.c
-    misc/fltused.c
-    misc/getargs.c
-    misc/i10output.c
-    misc/initterm.c
-    misc/lock.c
-    misc/purecall.c
-    misc/stubs.c
-    misc/tls.c
-    printf/_cprintf.c
-    printf/_cwprintf.c
-    printf/_scprintf.c
-    printf/_scwprintf.c
-    printf/_snprintf.c
-    printf/_snprintf_s.c
-    printf/_snwprintf.c
-    printf/_snwprintf_s.c
-    printf/_vcprintf.c
-    printf/_vcwprintf.c
-    printf/_vscprintf.c
-    printf/_vscwprintf.c
-    printf/_vsnprintf.c
-    printf/_vsnprintf_s.c
-    printf/_vsnwprintf.c
-    printf/_vsnwprintf_s.c
-    printf/_vsprintf_p.c
-    printf/fprintf.c
-    printf/fprintf_s.c
-    printf/fwprintf.c
-    printf/fwprintf_s.c
-    printf/printf.c
-    printf/printf_s.c
-    printf/sprintf.c
-    printf/sprintf_s.c
-    printf/streamout.c
-    printf/swprintf.c
-    printf/swprintf_s.c
-    printf/vfprintf.c
-    printf/vfprintf_s.c
-    printf/vfwprintf.c
-    printf/vfwprintf_s.c
-    printf/vprintf.c
-    printf/vprintf_s.c
-    printf/vsprintf.c
-    printf/vsprintf_s.c
-    printf/vswprintf.c
-    printf/vswprintf_s.c
-    printf/vwprintf.c
-    printf/vwprintf_s.c
-    printf/wprintf.c
-    printf/wprintf_s.c
-    printf/wstreamout.c
-    process/_cwait.c
-    process/_system.c
-    process/dll.c
-    process/process.c
-    process/procid.c
-    process/thread.c
-    process/threadid.c
-    process/threadx.c
-    process/wprocess.c
-    search/bsearch.c
-    search/lfind.c
-    search/lsearch.c
+    ${CRT_MATH_SOURCE}
+    ${CRT_MBSTRING_SOURCE}
+    ${CRT_MEM_SOURCE}
+    ${CRT_MISC_SOURCE}
+    ${CRT_PRINTF_SOURCE}
+    ${CRT_PROCESS_SOURCE}
+    ${CRT_SEARCH_SOURCE}
     signal/signal.c
     signal/xcptinfo.c
-    startup/crtexe.c
-    startup/wcrtexe.c
-    startup/crt_handler.c
-    startup/crtdll.c
-    startup/_newmode.c
-    startup/wildcard.c
-    startup/tlssup.c
-    startup/mingw_helpers.c
-    startup/natstart.c
-    startup/charmax.c
-    #startup/merr.c
-    startup/atonexit.c
-    #startup/txtmode.c
-    startup/pesect.c
-    startup/tlsmcrt.c
-    startup/tlsthrd.c
-    startup/tlsmthread.c
-    startup/cinitexe.c
-    startup/gs_support.c
-    startup/dll_argv.c
-    startup/dllargv.c
-    startup/wdllargv.c
-    startup/crt0_c.c
-    startup/crt0_w.c
-    startup/dllentry.c
-    startup/reactos.c
-    stdio/_flsbuf.c
-    stdio/_flswbuf.c
-    stdio/access.c
-    stdio/file.c
-    stdio/find.c
-    stdio/find64.c
-    stdio/findi64.c
-    stdio/fmode.c
-    stdio/perror.c
-    stdio/popen.c
-    stdio/stat.c
-    stdio/stat64.c
-    stdio/waccess.c
-    stdio/wfind.c
-    stdio/wfind64.c
-    stdio/wfindi64.c
-    stdio/wpopen.c
-    stdio/wstat.c
-    stdio/wstat64.c
-    stdlib/_exit.c
-    stdlib/_set_abort_behavior.c
-    stdlib/abort.c
-    stdlib/atexit.c
-    stdlib/ecvt.c
-    stdlib/errno.c
-    stdlib/fcvt.c
-    stdlib/fcvtbuf.c
-    stdlib/fullpath.c
-    stdlib/gcvt.c
-    stdlib/getenv.c
-    stdlib/makepath.c
-    stdlib/makepath_s.c
-    stdlib/mbtowc.c
-    stdlib/mbstowcs.c
-    stdlib/obsol.c
-    stdlib/putenv.c
-    stdlib/qsort.c
-    stdlib/rot.c
-    stdlib/senv.c
-    stdlib/swab.c
-    stdlib/wfulpath.c
-    stdlib/wputenv.c
-    stdlib/wsenv.c
-    stdlib/wmakpath.c
-    stdlib/wmakpath_s.c
-    string/_mbsnlen.c
-    string/_mbstrnlen.c
-    string/_splitpath.c
-    string/_splitpath_s.c
-    string/_wcslwr_s.c
-    string/_wsplitpath.c
-    string/_wsplitpath_s.c
-    string/atof.c
-    string/atoi.c
-    string/atoi64.c
-    string/atol.c
-    string/ctype.c
-    string/iswctype.c
-    string/is_wctype.c
-    string/itoa.c
-    string/itow.c
-    string/mbstowcs_s.c
-    string/scanf.c
-    string/strcoll.c
-    string/strcspn.c
-    string/strdup.c
-    string/strerror.c
-    string/stricmp.c
-    string/string.c
-    string/strlwr.c
-    string/strncoll.c
-    string/strnicmp.c
-    string/strpbrk.c
-    string/strrev.c
-    string/strset.c
-    string/strspn.c
-    string/strstr.c
-    string/strtod.c
-    string/strtoi64.c
-    string/strtok.c
-    string/strtok_s.c
-    string/strtol.c
-    string/strtoul.c
-    string/strtoull.c
-    string/strupr.c
-    string/strxfrm.c
-    string/wcs.c
-    string/wcstol.c
-    string/wcstombs_s.c
-    string/wcstoul.c
-    string/wctype.c
-    string/wtof.c
-    string/wtoi.c
-    string/wtoi64.c
-    string/wtol.c
-    string/winesup.c
+    ${CRT_STARTUP_SOURCE}
+    ${CRT_STDIO_SOURCE}
+    ${CRT_STDLIB_SOURCE}
+    ${CRT_STRING_SOURCE}
     sys_stat/systime.c
-    time/asctime.c
-    time/clock.c
-    time/ctime32.c
-    time/ctime64.c
-    time/ctime.c
-    time/difftime32.c
-    time/difftime64.c
-    time/difftime.c
-    time/ftime32.c
-    time/ftime64.c
-    time/ftime.c
-    time/futime32.c
-    time/futime64.c
-    time/futime.c
-    time/gmtime.c
-    time/localtime32.c
-    time/localtime64.c
-    time/localtime.c
-    time/mktime.c
-    time/strdate.c
-    time/strftime.c
-    time/strtime.c
-    time/time32.c
-    time/time64.c
-    time/time.c
-    time/timezone.c
-    time/utime32.c
-    time/utime64.c
-    time/utime.c
-    time/wasctime.c
-    time/wctime32.c
-    time/wctime64.c
-    time/wctime.c
-    time/wstrdate.c
-    time/wstrtime.c
-    time/wutime32.c
-    time/wutime64.c
-    time/wutime.c
-    wstring/wcscoll.c
-    wstring/wcscspn.c
-    wstring/wcsicmp.c
-    wstring/wcslwr.c
-    wstring/wcsnicmp.c
-    wstring/wcsspn.c
-    wstring/wcsstr.c
-    wstring/wcstok.c
-    wstring/wcsupr.c
-    wstring/wcsxfrm.c)
-
-list(APPEND CRT_WINE_SOURCE
-    wine/cpp.c
-    wine/except.c
-    wine/heap.c
-    wine/undname.c)
-
-if(ARCH STREQUAL "i386")
-    list(APPEND CRT_ASM_SOURCE
-        except/i386/chkesp.s
-        except/i386/prolog.s
-        math/i386/alldiv_asm.s
-        math/i386/alldvrm_asm.s
-        math/i386/allmul_asm.s
-        math/i386/allrem_asm.s
-        math/i386/allshl_asm.s
-        math/i386/allshr_asm.s
-        math/i386/atan_asm.s
-        math/i386/aulldiv_asm.s
-        math/i386/aulldvrm_asm.s
-        math/i386/aullrem_asm.s
-        math/i386/aullshr_asm.s
-        math/i386/ceil_asm.s
-        math/i386/ceilf.S
-        math/i386/cos_asm.s
-        math/i386/fabs_asm.s
-        math/i386/floor_asm.s
-        math/i386/floorf.S
-        math/i386/ftol_asm.s
-        math/i386/ftol2_asm.s
-        math/i386/log_asm.s
-        math/i386/log10_asm.s
-        math/i386/pow_asm.s
-        math/i386/sin_asm.s
-        math/i386/sqrt_asm.s
-        math/i386/tan_asm.s
-        math/i386/atan2_asm.s
-        math/i386/exp_asm.s
-        math/i386/fmod_asm.s
-        math/i386/fmodf_asm.s
-        mem/i386/memchr_asm.s
-        mem/i386/memmove_asm.s
-        mem/i386/memset_asm.s
-        misc/i386/readcr4.S
-        setjmp/i386/setjmp.s
-        string/i386/strcat_asm.s
-        string/i386/strchr_asm.s
-        string/i386/strcmp_asm.s
-        string/i386/strcpy_asm.s
-        string/i386/strlen_asm.s
-        string/i386/strncat_asm.s
-        string/i386/strncmp_asm.s
-        string/i386/strncpy_asm.s
-        string/i386/strnlen_asm.s
-        string/i386/strrchr_asm.s
-        string/i386/wcscat_asm.s
-        string/i386/wcschr_asm.s
-        string/i386/wcscmp_asm.s
-        string/i386/wcscpy_asm.s
-        string/i386/wcslen_asm.s
-        string/i386/wcsncat_asm.s
-        string/i386/wcsncmp_asm.s
-        string/i386/wcsncpy_asm.s
-        string/i386/wcsnlen_asm.s
-        string/i386/wcsrchr_asm.s)
-
-    list(APPEND CRT_SOURCE
-        float/i386/clearfp.c
-        float/i386/cntrlfp.c
-        float/i386/fpreset.c
-        float/i386/logb.c
-        float/i386/statfp.c
-        math/i386/ci.c
-        math/i386/cicos.c
-        math/i386/cilog.c
-        math/i386/cipow.c
-        math/i386/cisin.c
-        math/i386/cisqrt.c
-        math/i386/ldexp.c)
-    list(APPEND CRT_WINE_SOURCE
-        wine/except_i386.c)
-    if(MSVC)
-        list(APPEND CRT_ASM_SOURCE
-            except/i386/cpp.s)
-    endif()
-    if(USE_CLANG_CL)
-        list(APPEND CRT_ASM_SOURCE
-            stdlib/clang-alias.s)
-    endif()
-elseif(ARCH STREQUAL "amd64")
-    list(APPEND CRT_ASM_SOURCE
-        except/amd64/seh.s
-        float/amd64/clearfp.S
-        float/amd64/getsetfpcw.S
-        float/amd64/fpreset.S
-        float/amd64/logb.S
-        # math/amd64/acos.S
-        # math/amd64/acosf.S
-        math/amd64/atan.S
-        math/amd64/atan2.S
-        math/amd64/ceil.S
-        # math/amd64/ceilf.S
-        math/amd64/exp.S
-        math/amd64/fabs.S
-        math/amd64/floor.S
-        # math/amd64/floorf.S
-        math/amd64/fmod.S
-        # math/amd64/fmodf.S
-        math/amd64/ldexp.S
-        math/amd64/log.S
-        math/amd64/log10.S
-        math/amd64/pow.S
-        math/amd64/sqrt.S
-        # math/amd64/sqrtf.S
-        math/amd64/tan.S
-        setjmp/amd64/setjmp.s)
-
-    list(APPEND CRT_SOURCE
-        except/amd64/ehandler.c
-        float/i386/cntrlfp.c
-        float/i386/statfp.c)
-    list(APPEND CRT_WINE_SOURCE
-        wine/except_x86_64.c)
-    if(MSVC)
-        list(APPEND CRT_ASM_SOURCE
-            except/amd64/cpp.s)
-        if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
-            list(APPEND CRT_ASM_SOURCE
-                stdlib/clang-alias.s)
-        endif()
-    endif()
-elseif(ARCH STREQUAL "arm")
-    list(APPEND CRT_SOURCE
-        except/arm/ehandler.c
-        math/fabsf.c
-        math/sqrt.c
-        math/arm/__rt_sdiv.c
-        math/arm/__rt_sdiv64_worker.c
-        math/arm/__rt_udiv.c
-        math/arm/__rt_udiv64_worker.c
-    )
-    list(APPEND CRT_WINE_SOURCE
-        wine/except_arm.c
-    )
-    list(APPEND CRT_ASM_SOURCE
-        except/arm/_abnormal_termination.s
-        except/arm/_except_handler2.s
-        except/arm/_except_handler3.s
-        except/arm/_global_unwind2.s
-        except/arm/_local_unwind2.s
-        except/arm/chkstk_asm.s
-        float/arm/_clearfp.s
-        float/arm/_controlfp.s
-        float/arm/_fpreset.s
-        float/arm/_statusfp.s
-        math/arm/atan.s
-        math/arm/atan2.s
-        math/arm/ceil.s
-        math/arm/exp.s
-        math/arm/fabs.s
-        math/arm/fmod.s
-        math/arm/floor.s
-        math/arm/ldexp.s
-        math/arm/log.s
-        math/arm/log10.s
-        math/arm/pow.s
-        math/arm/tan.s
-        math/arm/_logb.s
-        math/arm/__dtoi64.s
-        math/arm/__dtou64.s
-        math/arm/__i64tod.s
-        math/arm/__i64tos.s
-        math/arm/__stoi64.s
-        math/arm/__stou64.s
-        math/arm/__u64tod.s
-        math/arm/__u64tos.s
-        math/arm/__rt_sdiv64.s
-        math/arm/__rt_srsh.s
-        math/arm/__rt_udiv64.s
-        setjmp/arm/setjmp.s
-    )
-    if(MSVC)
-        list(APPEND CRT_ASM_SOURCE
-            except/arm/cpp.s)
-    endif()
-endif()
-
-if(NOT ARCH STREQUAL "i386")
-    list(APPEND CRT_SOURCE
-        math/_chgsignf.c
-        math/_copysignf.c
-        math/_hypotf.c
-        math/acosf.c
-        math/asinf.c
-        math/atan2f.c
-        math/atanf.c
-        math/ceilf.c
-        math/cos.c
-        math/coshf.c
-        math/expf.c
-        math/floorf.c
-        math/fmodf.c
-        math/log10f.c
-        math/modff.c
-        math/sin.c
-        math/sinhf.c
-        math/sqrtf.c
-        math/tanf.c
-        math/tanhf.c
-        math/stubs.c
-        mem/memchr.c
-        mem/memcpy.c
-        mem/memmove.c
-        mem/memset.c
-        string/strcat.c
-        string/strchr.c
-        string/strcmp.c
-        string/strcpy.c
-        string/strlen.c
-        string/strncat.c
-        string/strncmp.c
-        string/strncpy.c
-        string/strnlen.c
-        string/strrchr.c
-        string/wcscat.c
-        string/wcschr.c
-        string/wcscmp.c
-        string/wcscpy.c
-        string/wcslen.c
-        string/wcsncat.c
-        string/wcsncmp.c
-        string/wcsncpy.c
-        string/wcsnlen.c
-        string/wcsrchr.c)
-endif()
-
-# includes for wine code
-include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
+    ${CRT_TIME_SOURCE}
+    ${CRT_WINE_SOURCE}
+    ${CRT_WSTRING_SOURCE}
+)
+
+list(APPEND CRT_ASM_SOURCE
+    ${CRT_EXCEPT_ASM_SOURCE}
+    ${CRT_FLOAT_ASM_SOURCE}
+    ${CRT_MATH_ASM_SOURCE}
+    ${CRT_SETJMP_ASM_SOURCE}
+    ${CRT_STDLIB_ASM_SOURCE}
+    ${CRT_STRING_ASM_SOURCE}
+)
 
 set_source_files_properties(${CRT_ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS 
"__MINGW_IMPORT=extern;USE_MSVCRT_PREFIX;_MSVCRT_LIB_;_MSVCRT_;_MT;CRTDLL")
 add_asm_files(crt_asm ${CRT_ASM_SOURCE})
 
-if(USE_CLANG_CL)
-    # clang-cl is missing pragma function support
-    # https://bugs.llvm.org/show_bug.cgi?id=35116
-    set_property(SOURCE stdlib/rot.c APPEND_STRING PROPERTY COMPILE_FLAGS " 
/fallback")
-endif()
-
-add_library(crt ${CRT_SOURCE} ${CRT_WINE_SOURCE} ${crt_asm})
+add_library(crt ${CRT_SOURCE} ${crt_asm})
 target_link_libraries(crt chkstk ${PSEH_LIB})
 target_compile_definitions(crt
  PRIVATE    __MINGW_IMPORT=extern
diff --git a/sdk/lib/crt/direct/direct.cmake b/sdk/lib/crt/direct/direct.cmake
new file mode 100644
index 00000000000..f713f6f00dd
--- /dev/null
+++ b/sdk/lib/crt/direct/direct.cmake
@@ -0,0 +1,16 @@
+
+list(APPEND CRT_DIRECT_SOURCE
+    direct/chdir.c
+    direct/chdrive.c
+    direct/getcwd.c
+    direct/getdcwd.c
+    direct/getdfree.c
+    direct/getdrive.c
+    direct/mkdir.c
+    direct/rmdir.c
+    direct/wchdir.c
+    direct/wgetcwd.c
+    direct/wgetdcwd.c
+    direct/wmkdir.c
+    direct/wrmdir.c 
+)
diff --git a/sdk/lib/crt/except/except.cmake b/sdk/lib/crt/except/except.cmake
new file mode 100644
index 00000000000..47ba7a43b88
--- /dev/null
+++ b/sdk/lib/crt/except/except.cmake
@@ -0,0 +1,85 @@
+
+if(ARCH STREQUAL "i386")
+    list(APPEND LIBCNTPR_EXCEPT_ASM_SOURCE
+        except/i386/chkstk_asm.s
+    )
+    if(NOT MSVC)
+        list(APPEND LIBCNTPR_EXCEPT_ASM_SOURCE
+            except/i386/chkstk_ms.s)
+    endif()
+    list(APPEND CRT_EXCEPT_ASM_SOURCE
+        except/i386/chkesp.s
+        except/i386/prolog.s
+    )
+    if(MSVC)
+        list(APPEND CRT_EXCEPT_ASM_SOURCE
+            except/i386/cpp.s)
+    endif()
+elseif(ARCH STREQUAL "amd64")
+    list(APPEND LIBCNTPR_EXCEPT_SOURCE
+        except/amd64/ehandler.c
+    )
+    list(APPEND LIBCNTPR_EXCEPT_ASM_SOURCE
+        except/amd64/chkstk_ms.s
+        except/amd64/seh.s
+    )
+    list(APPEND CRT_EXCEPT_ASM_SOURCE
+        except/amd64/seh.s
+    )
+    if(MSVC)
+        list(APPEND CRT_EXCEPT_ASM_SOURCE
+            except/amd64/cpp.s)
+    endif()
+elseif(ARCH STREQUAL "arm")
+    list(APPEND LIBCNTPR_EXCEPT_SOURCE
+        except/arm/ehandler.c
+    )
+    list(APPEND LIBCNTPR_EXCEPT_ASM_SOURCE
+        except/arm/__jump_unwind.s
+        except/arm/_abnormal_termination.s
+        except/arm/_except_handler2.s
+        except/arm/_except_handler3.s
+        except/arm/_global_unwind2.s
+        except/arm/_local_unwind2.s
+        except/arm/chkstk_asm.s
+    )
+    list(APPEND CRT_EXCEPT_ASM_SOURCE
+        except/arm/_abnormal_termination.s
+        except/arm/_except_handler2.s
+        except/arm/_except_handler3.s
+        except/arm/_global_unwind2.s
+        except/arm/_local_unwind2.s
+        except/arm/chkstk_asm.s
+    )
+    if(MSVC)
+        list(APPEND CRT_EXCEPT_ASM_SOURCE
+            except/arm/cpp.s)
+    endif()
+endif()
+
+list(APPEND CRT_EXCEPT_SOURCE
+    ${LIBCNTPR_EXCEPT_SOURCE}
+    except/matherr.c
+    except/stack.c
+)
+
+if(ARCH STREQUAL "i386")
+    list(APPEND CHKSTK_ASM_SOURCE except/i386/chkstk_asm.s)
+    if(NOT MSVC)
+        list(APPEND CHKSTK_ASM_SOURCE except/i386/chkstk_ms.s)
+    endif()
+elseif(ARCH STREQUAL "amd64")
+    list(APPEND CHKSTK_ASM_SOURCE except/amd64/chkstk_ms.s)
+elseif(ARCH STREQUAL "arm")
+    list(APPEND CHKSTK_ASM_SOURCE except/arm/chkstk_asm.s)
+    if(NOT MSVC)
+        list(APPEND CHKSTK_ASM_SOURCE except/arm/chkstk_ms.s)
+    endif()
+elseif(ARCH STREQUAL "powerpc")
+    list(APPEND CHKSTK_ASM_SOURCE except/powerpc/chkstk_asm.s)
+endif()
+
+add_asm_files(chkstk_lib_asm ${CHKSTK_ASM_SOURCE})
+add_library(chkstk ${CHKSTK_SOURCE} ${chkstk_lib_asm})
+set_target_properties(chkstk PROPERTIES LINKER_LANGUAGE "C")
+add_dependencies(chkstk asm)
diff --git a/sdk/lib/crt/float/float.cmake b/sdk/lib/crt/float/float.cmake
new file mode 100644
index 00000000000..5693f11e186
--- /dev/null
+++ b/sdk/lib/crt/float/float.cmake
@@ -0,0 +1,42 @@
+
+list(APPEND LIBCNTPR_FLOAT_SOURCE
+    float/isnan.c
+)
+
+list(APPEND CRT_FLOAT_SOURCE
+    ${LIBCNTPR_FLOAT_SOURCE}
+    float/chgsign.c
+    float/copysign.c
+    float/fpclass.c
+    float/fpecode.c
+    float/nafter.c
+    float/scalb.c
+)
+
+if(ARCH STREQUAL "i386")
+    list(APPEND CRT_FLOAT_SOURCE
+        float/i386/clearfp.c
+        float/i386/cntrlfp.c
+        float/i386/fpreset.c
+        float/i386/logb.c
+        float/i386/statfp.c
+    )
+elseif(ARCH STREQUAL "amd64")
+    list(APPEND CRT_FLOAT_SOURCE
+        float/i386/cntrlfp.c
+        float/i386/statfp.c
+    )
+    list(APPEND CRT_FLOAT_ASM_SOURCE
+        float/amd64/clearfp.S
+        float/amd64/getsetfpcw.S
+        float/amd64/fpreset.S
+        float/amd64/logb.S
+    )
+elseif(ARCH STREQUAL "arm")
+    list(APPEND CRT_FLOAT_ASM_SOURCE
+        float/arm/_clearfp.s
+        float/arm/_controlfp.s
+        float/arm/_fpreset.s
+        float/arm/_statusfp.s
+    )
+endif()
diff --git a/sdk/lib/crt/libcntpr.cmake b/sdk/lib/crt/libcntpr.cmake
index 178a18cd704..4105cbe4155 100644
--- a/sdk/lib/crt/libcntpr.cmake
+++ b/sdk/lib/crt/libcntpr.cmake
@@ -1,241 +1,26 @@
 
 list(APPEND LIBCNTPR_SOURCE
-    float/isnan.c
-    math/abs.c
-    math/div.c
-    math/labs.c
-    math/rand_nt.c
-    mbstring/mbstrlen.c
-    mem/memccpy.c
-    mem/memcmp.c
-    mem/memicmp.c
-    misc/fltused.c
-    printf/_snprintf.c
-    printf/_snwprintf.c
-    printf/_vscprintf.c
-    printf/_vscwprintf.c
-    printf/_vsnprintf.c
-    printf/_vsnwprintf.c
-    printf/sprintf.c
-    printf/streamout.c
-    printf/swprintf.c
-    printf/vprintf.c
-    printf/vsprintf.c
-    printf/vswprintf.c
-    printf/wstreamout.c
-    search/bsearch.c
-    search/lfind.c
-    stdlib/qsort.c
-    string/_splitpath.c
-    string/_wsplitpath.c
-    string/ctype.c
-    string/iswctype.c
-    string/is_wctype.c
-    string/scanf.c
-    string/strcspn.c
-    string/stricmp.c
-    string/strnicmp.c
-    string/strlwr.c
-    string/strrev.c
-    string/strset.c
-    string/strstr.c
-    string/strupr.c
-    string/strpbrk.c
-    string/strspn.c
-    string/atoi64.c
-    string/atoi.c
-    string/atol.c
-    string/itoa.c
-    string/itow.c
-    string/mbstowcs_nt.c
-    string/strtoi64.c
-    string/strtol.c
-    string/strtoul.c
-    string/strtoull.c
-    string/wcs.c
-    string/wcstol.c
-    string/wcstombs_nt.c
-    string/wcstoul.c
-    string/wctype.c
-    string/wtoi64.c
-    string/wtoi.c
-    string/wtol.c
-    string/winesup.c
-    wstring/wcsicmp.c
-    wstring/wcslwr.c
-    wstring/wcsnicmp.c
-    wstring/wcsupr.c
-    wstring/wcscspn.c
-    wstring/wcsspn.c
-    wstring/wcsstr.c)
+    ${LIBCNTPR_EXCEPT_SOURCE}
+    ${LIBCNTPR_FLOAT_SOURCE}
+    ${LIBCNTPR_MATH_SOURCE}
+    ${LIBCNTPR_MBSTRING_SOURCE}
+    ${LIBCNTPR_MEM_SOURCE}
+    ${LIBCNTPT_MISC_SOURCE}
+    ${LIBCNTPR_PRINTF_SOURCE}
+    ${LIBCNTPR_SEARCH_SOURCE}
+    ${LIBCNTPR_STDLIB_SOURCE}
+    ${LIBCNTPR_STRING_SOURCE}
+    ${LIBCNTPR_WSTRING_SOURCE}
+)
 
-if(ARCH STREQUAL "i386")
-    list(APPEND LIBCNTPR_ASM_SOURCE
-        except/i386/chkstk_asm.s
-        setjmp/i386/setjmp.s
-        math/i386/alldiv_asm.s
-        math/i386/alldvrm_asm.s
-        math/i386/allmul_asm.s
-        math/i386/allrem_asm.s
-        math/i386/allshl_asm.s
-        math/i386/allshr_asm.s
-        math/i386/atan_asm.s
-        math/i386/atan2_asm.s
-        math/i386/aulldiv_asm.s
-        math/i386/aulldvrm_asm.s
-        math/i386/aullrem_asm.s
-        math/i386/aullshr_asm.s
-        math/i386/ceil_asm.s
-        math/i386/cos_asm.s
-        math/i386/fabs_asm.s
-        math/i386/floor_asm.s
-        math/i386/ftol_asm.s
-        math/i386/ftol2_asm.s
-        math/i386/log_asm.s
-        math/i386/log10_asm.s
-        math/i386/pow_asm.s
-        math/i386/sin_asm.s
-        math/i386/sqrt_asm.s
-        math/i386/tan_asm.s
-        misc/i386/readcr4.S)
-
-    list(APPEND LIBCNTPR_SOURCE
-        math/i386/ci.c
-        math/i386/cicos.c
-        math/i386/cilog.c
-        math/i386/cipow.c
-        math/i386/cisin.c
-        math/i386/cisqrt.c
-        math/i386/ldexp.c)
-    if(NOT MSVC)
-        list(APPEND LIBCNTPR_SOURCE except/i386/chkstk_ms.s)
-    endif()
-elseif(ARCH STREQUAL "amd64")
-    list(APPEND LIBCNTPR_ASM_SOURCE
-        except/amd64/chkstk_ms.s
-        except/amd64/seh.s
-        setjmp/amd64/setjmp.s
-        math/amd64/atan.S
-        math/amd64/atan2.S
-        math/amd64/ceil.S
-        math/amd64/exp.S
-        math/amd64/fabs.S
-        math/amd64/floor.S
-        math/amd64/floorf.S
-        math/amd64/fmod.S
-        math/amd64/ldexp.S
-        math/amd64/log.S
-        math/amd64/log10.S
-        math/amd64/pow.S
-        math/amd64/sqrt.S
-        math/amd64/tan.S)
-    list(APPEND LIBCNTPR_SOURCE
-        except/amd64/ehandler.c
-        math/cos.c
-        math/sin.c)
-elseif(ARCH STREQUAL "arm")
-    list(APPEND LIBCNTPR_SOURCE
-        except/arm/chkstk_asm.s
-        except/arm/__jump_unwind.s
-        math/sqrt.c
-        math/arm/__rt_sdiv.c
-        math/arm/__rt_sdiv64_worker.c
-        math/arm/__rt_udiv.c
-        math/arm/__rt_udiv64_worker.c
-    )
-    list(APPEND LIBCNTPR_ASM_SOURCE
-        except/arm/_abnormal_termination.s
-        except/arm/_except_handler2.s
-        except/arm/_except_handler3.s
-        except/arm/_global_unwind2.s
-        except/arm/_local_unwind2.s
-        except/arm/chkstk_asm.s
-        except/arm/ehandler.c
-        float/arm/_clearfp.s
-        float/arm/_controlfp.s
-        float/arm/_fpreset.s
-        float/arm/_statusfp.s
-        math/arm/atan.s
-        math/arm/atan2.s
-        math/arm/ceil.s
-        math/arm/exp.s
-        math/arm/fabs.s
-        math/arm/fmod.s
-        math/arm/floor.s
-        math/arm/ldexp.s
-        math/arm/log.s
-        math/arm/log10.s
-        math/arm/pow.s
-        math/arm/tan.s
-        math/arm/__dtoi64.s
-        math/arm/__dtou64.s
-        math/arm/__i64tod.s
-        math/arm/__i64tos.s
-        math/arm/__stoi64.s
-        math/arm/__stou64.s
-        math/arm/__u64tod.s
-        math/arm/__u64tos.s
-        math/arm/__rt_sdiv64.s
-        math/arm/__rt_srsh.s
-        math/arm/__rt_udiv64.s
-        setjmp/arm/setjmp.s
-    )
-endif()
-
-if(ARCH STREQUAL "i386")
-    list(APPEND LIBCNTPR_ASM_SOURCE
-        mem/i386/memchr_asm.s
-        mem/i386/memmove_asm.s
-        mem/i386/memset_asm.s
-        string/i386/strcat_asm.s
-        string/i386/strchr_asm.s
-        string/i386/strcmp_asm.s
-        string/i386/strcpy_asm.s
-        string/i386/strlen_asm.s
-        string/i386/strncat_asm.s
-        string/i386/strncmp_asm.s
-        string/i386/strncpy_asm.s
-        string/i386/strnlen_asm.s
-        string/i386/strrchr_asm.s
-        string/i386/wcscat_asm.s
-        string/i386/wcschr_asm.s
-        string/i386/wcscmp_asm.s
-        string/i386/wcscpy_asm.s
-        string/i386/wcslen_asm.s
-        string/i386/wcsncat_asm.s
-        string/i386/wcsncmp_asm.s
-        string/i386/wcsncpy_asm.s
-        string/i386/wcsnlen_asm.s
-        string/i386/wcsrchr_asm.s)
-else()
-    list(APPEND LIBCNTPR_SOURCE
-        math/cos.c
-        math/sin.c
-        mem/memchr.c
-        mem/memcpy.c
-        mem/memmove.c
-        mem/memset.c
-        string/strcat.c
-        string/strchr.c
-        string/strcmp.c
-        string/strcpy.c
-        string/strlen.c
-        string/strncat.c
-        string/strncmp.c
-        string/strncpy.c
-        string/strnlen.c
-        string/strrchr.c
-        string/wcscat.c
-        string/wcschr.c
-        string/wcscmp.c
-        string/wcscpy.c
-        string/wcslen.c
-        string/wcsncat.c
-        string/wcsncmp.c
-        string/wcsncpy.c
-        string/wcsnlen.c
-        string/wcsrchr.c)
-endif()
+list(APPEND LIBCNTPR_ASM_SOURCE
+    ${LIBCNTPR_EXCEPT_ASM_SOURCE}
+    ${LIBCNTPR_FLOAT_ASM_SOURCE}
+    ${LIBCNTPR_MATH_ASM_SOURCE}
+    ${LIBCNTPR_MEM_ASM_SOURCE}
+    ${LIBCNTPR_SETJMP_ASM_SOURCE}
+    ${LIBCNTPR_STRING_ASM_SOURCE}
+)
 
 set_source_files_properties(${LIBCNTPR_ASM_SOURCE} PROPERTIES 
COMPILE_DEFINITIONS 
"NO_RTL_INLINES;_NTSYSTEM_;_NTDLLBUILD_;_LIBCNT_;__CRT__NO_INLINE;CRTDLL")
 add_asm_files(libcntpr_asm ${LIBCNTPR_ASM_SOURCE})
diff --git a/sdk/lib/crt/math/math.cmake b/sdk/lib/crt/math/math.cmake
new file mode 100644
index 00000000000..a11c62ccb3f
--- /dev/null
+++ b/sdk/lib/crt/math/math.cmake
@@ -0,0 +1,189 @@
+
+list(APPEND LIBCNTPR_MATH_SOURCE
+    math/abs.c
+    math/div.c
+    math/labs.c
+)
+
+if(ARCH STREQUAL "i386")
+    list(APPEND LIBCNTPR_MATH_SOURCE
+        math/i386/ci.c
+        math/i386/cicos.c
+        math/i386/cilog.c
+        math/i386/cipow.c
+        math/i386/cisin.c
+        math/i386/cisqrt.c
+        math/i386/ldexp.c
+    )
+    list(APPEND LIBCNTPR_MATH_ASM_SOURCE
+        math/i386/alldiv_asm.s
+        math/i386/alldvrm_asm.s
+        math/i386/allmul_asm.s
+        math/i386/allrem_asm.s
+        math/i386/allshl_asm.s
+        math/i386/allshr_asm.s
+        math/i386/atan_asm.s
+        math/i386/atan2_asm.s
+        math/i386/aulldiv_asm.s
+        math/i386/aulldvrm_asm.s
+        math/i386/aullrem_asm.s
+        math/i386/aullshr_asm.s
+        math/i386/ceil_asm.s
+        math/i386/cos_asm.s
+        math/i386/fabs_asm.s
+        math/i386/floor_asm.s
+        math/i386/ftol_asm.s
+        math/i386/ftol2_asm.s
+        math/i386/log_asm.s
+        math/i386/log10_asm.s
+        math/i386/pow_asm.s
+        math/i386/sin_asm.s
+        math/i386/sqrt_asm.s
+        math/i386/tan_asm.s
+    )
+    list(APPEND CRT_MATH_ASM_SOURCE
+        math/i386/ceilf.S
+        math/i386/floorf.S
+        math/i386/exp_asm.s
+        math/i386/fmod_asm.s
+        math/i386/fmodf_asm.s
+    )
+elseif(ARCH STREQUAL "amd64")
+    list(APPEND LIBCNTPR_MATH_SOURCE
+        math/cos.c
+        math/sin.c
+    )
+    list(APPEND LIBCNTPR_MATH_ASM_SOURCE
+        math/amd64/atan.S
+        math/amd64/atan2.S
+        math/amd64/ceil.S
+        math/amd64/exp.S
+        math/amd64/fabs.S
+        math/amd64/floor.S
+        math/amd64/floorf.S
+        math/amd64/fmod.S
+        math/amd64/ldexp.S
+        math/amd64/log.S
+        math/amd64/log10.S
+        math/amd64/pow.S
+        math/amd64/sqrt.S
+        math/amd64/tan.S
+    )
+elseif(ARCH STREQUAL "arm")
+    list(APPEND LIBCNTPR_MATH_SOURCE
+        math/cos.c
+        math/sin.c
+        math/sqrt.c
+        math/arm/__rt_sdiv.c
+        math/arm/__rt_sdiv64_worker.c
+        math/arm/__rt_udiv.c
+        math/arm/__rt_udiv64_worker.c
+    )
+    list(APPEND CRT_MATH_SOURCE
+        math/fabsf.c
+    )
+    list(APPEND LIBCNTPR_MATH_ASM_SOURCE
+        math/arm/atan.s
+        math/arm/atan2.s
+        math/arm/ceil.s
+        math/arm/exp.s
+        math/arm/fabs.s
+        math/arm/fmod.s
+        math/arm/floor.s
+        math/arm/ldexp.s
+        math/arm/log.s
+        math/arm/log10.s
+        math/arm/pow.s
+        math/arm/tan.s
+        math/arm/__dtoi64.s
+        math/arm/__dtou64.s
+        math/arm/__i64tod.s
+        math/arm/__i64tos.s
+        math/arm/__stoi64.s
+        math/arm/__stou64.s
+        math/arm/__u64tod.s
+        math/arm/__u64tos.s
+        math/arm/__rt_sdiv64.s
+        math/arm/__rt_srsh.s
+        math/arm/__rt_udiv64.s
+    )
+    list(APPEND CRT_MATH_ASM_SOURCE
+        math/arm/_logb.s
+    )
+endif()
+
+if(NOT ARCH STREQUAL "i386")
+    list(APPEND CRT_MATH_SOURCE
+        math/_chgsignf.c
+        math/_copysignf.c
+        math/_hypotf.c
+        math/acosf.c
+        math/asinf.c
+        math/atan2f.c
+        math/atanf.c
+        math/ceilf.c
+        math/cos.c
+        math/coshf.c
+        math/expf.c
+        math/floorf.c
+        math/fmodf.c
+        math/log10f.c
+        math/modff.c
+        math/sin.c
+        math/sinhf.c
+        math/sqrtf.c
+        math/tanf.c
+        math/tanhf.c
+        math/stubs.c
+    )
+endif()
+
+list(APPEND CRT_MATH_SOURCE
+    ${LIBCNTPR_MATH_SOURCE}
+    math/acos.c
+    math/adjust.c
+    math/asin.c
+    math/cabs.c
+    math/cosf.c
+    math/cosh.c
+    math/fdivbug.c
+    math/frexp.c
+    math/huge_val.c
+    math/hypot.c
+    math/ieee754/j0_y0.c
+    math/ieee754/j1_y1.c
+    math/ieee754/jn_yn.c
+    math/j0_y0.c
+    math/j1_y1.c
+    math/jn_yn.c
+    math/ldiv.c
+    math/logf.c
+    math/modf.c
+    math/powf.c
+    math/rand.c
+    math/s_modf.c
+    math/sinf.c
+    math/sinh.c
+    math/tanh.c
+)
+
+list(APPEND CRT_MATH_ASM_SOURCE
+    ${LIBCNTPR_MATH_ASM_SOURCE}
+)
+
+list(APPEND LIBCNTPR_MATH_SOURCE
+    math/rand_nt.c
+)
+
+if(ARCH STREQUAL "i386")
+    list(APPEND ATAN2_ASM_SOURCE math/i386/atan2_asm.s)
+elseif(ARCH STREQUAL "amd64")
+    list(APPEND ATAN2_ASM_SOURCE math/amd64/atan2.S)
+elseif(ARCH STREQUAL "arm")
+    list(APPEND ATAN2_ASM_SOURCE math/arm/atan2.s)
+endif()
+
+add_asm_files(atan2_asm ${ATAN2_ASM_SOURCE})
+add_library(atan2 ${atan2_asm})
+set_target_properties(atan2 PROPERTIES LINKER_LANGUAGE "C")
+add_dependencies(atan2 asm)
diff --git a/sdk/lib/crt/mbstring/mbstring.cmake 
b/sdk/lib/crt/mbstring/mbstring.cmake
new file mode 100644
index 00000000000..6851ccef550
--- /dev/null
+++ b/sdk/lib/crt/mbstring/mbstring.cmake
@@ -0,0 +1,63 @@
+
+list(APPEND LIBCNTPR_MBSTRING_SOURCE
+    mbstring/mbstrlen.c
+)
+
+list(APPEND CRT_MBSTRING_SOURCE
+    ${LIBCNTPR_MBSTRING_SOURCE}
+    mbstring/_setmbcp.c
+    mbstring/hanzen.c
+    mbstring/ischira.c
+    mbstring/iskana.c
+    mbstring/iskmoji.c
+    mbstring/iskpun.c
+    mbstring/islead.c
+    mbstring/islwr.c
+    mbstring/ismbal.c
+    mbstring/ismbaln.c
+    mbstring/ismbc.c
+    mbstring/ismbgra.c
+    mbstring/ismbkaln.c
+    mbstring/ismblead.c
+    mbstring/ismbpri.c
+    mbstring/ismbpun.c
+    mbstring/ismbtrl.c
+    mbstring/isuppr.c
+    mbstring/jistojms.c
+    mbstring/jmstojis.c
+    mbstring/mbbtype.c
+    mbstring/mbccpy.c
+    mbstring/mbclen.c
+    mbstring/mbscat.c
+    mbstring/mbschr.c
+    mbstring/mbscmp.c
+    mbstring/mbscoll.c
+    mbstring/mbscpy.c
+    mbstring/mbscspn.c
+    mbstring/mbsdec.c
+    mbstring/mbsdup.c
+    mbstring/mbsicmp.c
+    mbstring/mbsicoll.c
+    mbstring/mbsinc.c
+    mbstring/mbslen.c
+    mbstring/mbslwr.c
+    mbstring/mbsncat.c
+    mbstring/mbsnccnt.c
+    mbstring/mbsncmp.c
+    mbstring/mbsncoll.c
+    mbstring/mbsncpy.c
+    mbstring/mbsnextc.c
+    mbstring/mbsnicmp.c
+    mbstring/mbsnicoll.c
+    mbstring/mbsninc.c
+    mbstring/mbsnset.c
+    mbstring/mbspbrk.c
+    mbstring/mbsrchr.c
+    mbstring/mbsrev.c
+    mbstring/mbsset.c
+    mbstring/mbsspn.c
+    mbstring/mbsspnp.c
+    mbstring/mbsstr.c
+    mbstring/mbstok.c
+    mbstring/mbsupr.c
+)
diff --git a/sdk/lib/crt/mem/mem.cmake b/sdk/lib/crt/mem/mem.cmake
new file mode 100644
index 00000000000..cc5d04a5a66
--- /dev/null
+++ b/sdk/lib/crt/mem/mem.cmake
@@ -0,0 +1,32 @@
+
+list(APPEND LIBCNTPR_MEM_SOURCE
+    mem/memccpy.c
+    mem/memcmp.c
+    mem/memicmp.c
+)
+
+if(ARCH STREQUAL "i386")
+    list(APPEND LIBCNTPR_MEM_ASM_SOURCE
+        mem/i386/memchr_asm.s
+        mem/i386/memmove_asm.s
+        mem/i386/memset_asm.s
+    )
+    list(APPEND CRT_MEM_ASM_SOURCE
+        ${LIBCNTPR_MEM_ASM_SOURCE}
+    )
+else()
+    list(APPEND LIBCNTPR_MEM_SOURCE
+        mem/memchr.c
+        mem/memcpy.c
+        mem/memmove.c
+        mem/memset.c
+    )
+endif()
+
+list(APPEND CRT_MEM_SOURCE
+    ${LIBCNTPR_MEM_SOURCE}
+)
+
+# Needed by ext2fs. Should use RtlCompareMemory instead?
+add_library(memcmp mem/memcmp.c)
+add_dependencies(memcmp psdk)
diff --git a/sdk/lib/crt/misc/misc.cmake b/sdk/lib/crt/misc/misc.cmake
new file mode 100644
index 00000000000..18abea274c1
--- /dev/null
+++ b/sdk/lib/crt/misc/misc.cmake
@@ -0,0 +1,29 @@
+
+list(APPEND LIBCNTPT_MISC_SOURCE
+    misc/fltused.c
+)
+
+if(ARCH STREQUAL "i386")
+    list(APPEND LIBCNTPR_ASM_SOURCE
+        misc/i386/readcr4.S
+    )
+endif()
+
+list(APPEND CRT_MISC_SOURCE
+    ${LIBCNTPT_MISC_SOURCE}
+    misc/__crt_MessageBoxA.c
+    misc/amsg.c
+    misc/assert.c
+    misc/environ.c
+    misc/getargs.c
+    misc/i10output.c
+    misc/initterm.c
+    misc/lock.c
+    misc/purecall.c
+    misc/stubs.c
+    misc/tls.c
+)
+
+add_library(getopt misc/getopt.c)
+target_compile_definitions(getopt PRIVATE _DLL __USE_CRTIMP)
+add_dependencies(getopt psdk)
diff --git a/sdk/lib/crt/printf/printf.cmake b/sdk/lib/crt/printf/printf.cmake
new file mode 100644
index 00000000000..7b68b88e360
--- /dev/null
+++ b/sdk/lib/crt/printf/printf.cmake
@@ -0,0 +1,50 @@
+
+list(APPEND LIBCNTPR_PRINTF_SOURCE
+    printf/_snprintf.c
+    printf/_snwprintf.c
+    printf/_vscprintf.c
+    printf/_vscwprintf.c
+    printf/_vsnprintf.c
+    printf/_vsnwprintf.c
+    printf/sprintf.c
+    printf/streamout.c
+    printf/swprintf.c
+    printf/vprintf.c
+    printf/vsprintf.c
+    printf/vswprintf.c
+    printf/wstreamout.c
+)
+
+list(APPEND CRT_PRINTF_SOURCE
+    ${LIBCNTPR_PRINTF_SOURCE}
+    printf/_cprintf.c
+    printf/_cwprintf.c
+    printf/_scprintf.c
+    printf/_scwprintf.c
+    printf/_snprintf_s.c
+    printf/_snwprintf_s.c
+    printf/_vcprintf.c
+    printf/_vcwprintf.c
+    printf/_vsnprintf_s.c
+    printf/_vsnwprintf_s.c
+    printf/_vsprintf_p.c
+    printf/fprintf.c
+    printf/fprintf_s.c
+    printf/fwprintf.c
+    printf/fwprintf_s.c
+    printf/printf.c
+    printf/printf_s.c
+    printf/sprintf_s.c
+    printf/swprintf_s.c
+    printf/vfprintf.c
+    printf/vfprintf_s.c
+    printf/vfwprintf.c
+    printf/vfwprintf_s.c
+    printf/vprintf_s.c
+    printf/vsprintf_s.c
+    printf/vswprintf_s.c
+    printf/vwprintf.c
+    printf/vwprintf_s.c
+    printf/wprintf.c
+    printf/wprintf_s.c
+)
diff --git a/sdk/lib/crt/process/process.cmake 
b/sdk/lib/crt/process/process.cmake
new file mode 100644
index 00000000000..d84b3484c7d
--- /dev/null
+++ b/sdk/lib/crt/process/process.cmake
@@ -0,0 +1,12 @@
+
+list(APPEND CRT_PROCESS_SOURCE
+    process/_cwait.c
+    process/_system.c
+    process/dll.c
+    process/process.c
+    process/procid.c
+    process/thread.c
+    process/threadid.c
+    process/threadx.c
+    process/wprocess.c
+)
diff --git a/sdk/lib/crt/search/search.cmake b/sdk/lib/crt/search/search.cmake
new file mode 100644
index 00000000000..066088c2cfa
--- /dev/null
+++ b/sdk/lib/crt/search/search.cmake
@@ -0,0 +1,10 @@
+
+list(APPEND LIBCNTPR_SEARCH_SOURCE
+    search/bsearch.c
+    search/lfind.c
+)
+
+list(APPEND CRT_SEARCH_SOURCE
+    ${LIBCNTPR_SEARCH_SOURCE}
+    search/lsearch.c
+)
diff --git a/sdk/lib/crt/setjmp/setjmp.cmake b/sdk/lib/crt/setjmp/setjmp.cmake
new file mode 100644
index 00000000000..05ff378f7b5
--- /dev/null
+++ b/sdk/lib/crt/setjmp/setjmp.cmake
@@ -0,0 +1,18 @@
+
+if(ARCH STREQUAL "i386")
+    list(APPEND LIBCNTPR_SETJMP_ASM_SOURCE
+        setjmp/i386/setjmp.s
+    )
+elseif(ARCH STREQUAL "amd64")
+    list(APPEND LIBCNTPR_SETJMP_ASM_SOURCE
+        setjmp/amd64/setjmp.s
+    )
+elseif(ARCH STREQUAL "arm")
+    list(APPEND LIBCNTPR_SETJMP_ASM_SOURCE
+        setjmp/arm/setjmp.s
+    )
+endif()
+
+list(APPEND CRT_SETJMP_ASM_SOURCE
+    ${LIBCNTPR_SETJMP_ASM_SOURCE}
+)
diff --git a/sdk/lib/crt/startup/startup.cmake 
b/sdk/lib/crt/startup/startup.cmake
new file mode 100644
index 00000000000..b2d3070c12d
--- /dev/null
+++ b/sdk/lib/crt/startup/startup.cmake
@@ -0,0 +1,29 @@
+
+list(APPEND CRT_STARTUP_SOURCE
+    startup/crtexe.c
+    startup/wcrtexe.c
+    startup/crt_handler.c
+    startup/crtdll.c
+    startup/_newmode.c
+    startup/wildcard.c
+    startup/tlssup.c
+    startup/mingw_helpers.c
+    startup/natstart.c
+    startup/charmax.c
+    #startup/merr.c
+    startup/atonexit.c
+    #startup/txtmode.c
+    startup/pesect.c
+    startup/tlsmcrt.c
+    startup/tlsthrd.c
+    startup/tlsmthread.c
+    startup/cinitexe.c
+    startup/gs_support.c
+    startup/dll_argv.c
+    startup/dllargv.c
+    startup/wdllargv.c
+    startup/crt0_c.c
+    startup/crt0_w.c
+    startup/dllentry.c
+    startup/reactos.c
+)
diff --git a/sdk/lib/crt/stdio/stdio.cmake b/sdk/lib/crt/stdio/stdio.cmake
new file mode 100644
index 00000000000..7b2974a2ae8
--- /dev/null
+++ b/sdk/lib/crt/stdio/stdio.cmake
@@ -0,0 +1,22 @@
+
+list(APPEND CRT_STDIO_SOURCE
+    stdio/_flsbuf.c
+    stdio/_flswbuf.c
+    stdio/access.c
+    stdio/file.c
+    stdio/find.c
+    stdio/find64.c
+    stdio/findi64.c
+    stdio/fmode.c
+    stdio/perror.c
+    stdio/popen.c
+    stdio/stat.c
+    stdio/stat64.c
+    stdio/waccess.c
+    stdio/wfind.c
+    stdio/wfind64.c
+    stdio/wfindi64.c
+    stdio/wpopen.c
+    stdio/wstat.c
+    stdio/wstat64.c
+)
diff --git a/sdk/lib/crt/stdlib/stdlib.cmake b/sdk/lib/crt/stdlib/stdlib.cmake
new file mode 100644
index 00000000000..5325319f839
--- /dev/null
+++ b/sdk/lib/crt/stdlib/stdlib.cmake
@@ -0,0 +1,49 @@
+
+list(APPEND LIBCNTPR_STDLIB_SOURCE
+    stdlib/qsort.c
+)
+
+list(APPEND CRT_STDLIB_SOURCE
+    ${LIBCNTPR_STDLIB_SOURCE}
+    stdlib/_exit.c
+    stdlib/_set_abort_behavior.c
+    stdlib/abort.c
+    stdlib/atexit.c
+    stdlib/ecvt.c
+    stdlib/errno.c
+    stdlib/fcvt.c
+    stdlib/fcvtbuf.c
+    stdlib/fullpath.c
+    stdlib/gcvt.c
+    stdlib/getenv.c
+    stdlib/makepath.c
+    stdlib/makepath_s.c
+    stdlib/mbtowc.c
+    stdlib/mbstowcs.c
+    stdlib/obsol.c
+    stdlib/putenv.c
+    stdlib/rot.c
+    stdlib/senv.c
+    stdlib/swab.c
+    stdlib/wfulpath.c
+    stdlib/wputenv.c
+    stdlib/wsenv.c
+    stdlib/wmakpath.c
+    stdlib/wmakpath_s.c
+)
+
+if(USE_CLANG_CL)
+    # clang-cl is missing pragma function support
+    # https://bugs.llvm.org/show_bug.cgi?id=35116
+    set_property(SOURCE stdlib/rot.c APPEND_STRING PROPERTY COMPILE_FLAGS " 
/fallback")
+
+    if(ARCH STREQUAL "i386")
+        list(APPEND CRT_STDLIB_ASM_SOURCE
+            stdlib/clang-alias.s
+        )
+    elseif(ARCH STREQUAL "amd64")
+        list(APPEND CRT_STDLIB_ASM_SOURCE
+            stdlib/clang-alias.s
+        )
+    endif()
+endif()
diff --git a/sdk/lib/crt/string/string.cmake b/sdk/lib/crt/string/string.cmake
new file mode 100644
index 00000000000..e7e95c8a1b6
--- /dev/null
+++ b/sdk/lib/crt/string/string.cmake
@@ -0,0 +1,128 @@
+
+list(APPEND LIBCNTPR_STRING_SOURCE
+    string/_splitpath.c
+    string/_wsplitpath.c
+    string/ctype.c
+    string/iswctype.c
+    string/is_wctype.c
+    string/scanf.c
+    string/strcspn.c
+    string/stricmp.c
+    string/strnicmp.c
+    string/strlwr.c
+    string/strrev.c
+    string/strset.c
+    string/strstr.c
+    string/strupr.c
+    string/strpbrk.c
+    string/strspn.c
+    string/atoi64.c
+    string/atoi.c
+    string/atol.c
+    string/itoa.c
+    string/itow.c
+    string/strtoi64.c
+    string/strtol.c
+    string/strtoul.c
+    string/strtoull.c
+    string/wcs.c
+    string/wcstol.c
+    string/wcstoul.c
+    string/wctype.c
+    string/wtoi64.c
+    string/wtoi.c
+    string/wtol.c
+    string/winesup.c
+)
+
+if(ARCH STREQUAL "i386")
+    list(APPEND LIBCNTPR_STRING_ASM_SOURCE
+        string/i386/strcat_asm.s
+        string/i386/strchr_asm.s
+        string/i386/strcmp_asm.s
+        string/i386/strcpy_asm.s
+        string/i386/strlen_asm.s
+        string/i386/strncat_asm.s
+        string/i386/strncmp_asm.s
+        string/i386/strncpy_asm.s
+        string/i386/strnlen_asm.s
+        string/i386/strrchr_asm.s
+        string/i386/wcscat_asm.s
+        string/i386/wcschr_asm.s
+        string/i386/wcscmp_asm.s
+        string/i386/wcscpy_asm.s
+        string/i386/wcslen_asm.s
+        string/i386/wcsncat_asm.s
+        string/i386/wcsncmp_asm.s
+        string/i386/wcsncpy_asm.s
+        string/i386/wcsnlen_asm.s
+        string/i386/wcsrchr_asm.s
+    )
+else()
+    list(APPEND LIBCNTPR_STRING_SOURCE
+        string/strcat.c
+        string/strchr.c
+        string/strcmp.c
+        string/strcpy.c
+        string/strlen.c
+        string/strncat.c
+        string/strncmp.c
+        string/strncpy.c
+        string/strnlen.c
+        string/strrchr.c
+        string/wcscat.c
+        string/wcschr.c
+        string/wcscmp.c
+        string/wcscpy.c
+        string/wcslen.c
+        string/wcsncat.c
+        string/wcsncmp.c
+        string/wcsncpy.c
+        string/wcsnlen.c
+        string/wcsrchr.c
+    )
+endif()
+
+list(APPEND CRT_STRING_SOURCE
+    ${LIBCNTPR_STRING_SOURCE}
+    string/_mbsnlen.c
+    string/_mbstrnlen.c
+    string/_splitpath_s.c
+    string/_wcslwr_s.c
+    string/_wsplitpath_s.c
+    string/atof.c
+    string/mbstowcs_s.c
+    string/strcoll.c
+    string/strdup.c
+    string/strerror.c
+    string/string.c
+    string/strncoll.c
+    string/strtod.c
+    string/strtok.c
+    string/strtok_s.c
+    string/strtoul.c
+    string/strxfrm.c
+    string/wcstombs_s.c
+    string/wtof.c
+)
+
+list(APPEND CRT_STRING_ASM_SOURCE
+    ${LIBCNTPR_STRING_ASM_SOURCE}
+)
+
+list(APPEND LIBCNTPR_STRING_SOURCE
+    string/mbstowcs_nt.c
+    string/wcstombs_nt.c
+)
+
+# Used by acpi.sys
+add_library(strtol
+    string/ctype.c
+    string/iswctype.c
+    string/strtoi64.c
+    string/strtol.c
+    string/strtoul.c
+    string/strtoull.c
+    string/wctype.c)
+target_compile_definitions(strtol PRIVATE _LIBCNT_)
+add_dependencies(strtol psdk)
diff --git a/sdk/lib/crt/time/time.cmake b/sdk/lib/crt/time/time.cmake
new file mode 100644
index 00000000000..f6459f55538
--- /dev/null
+++ b/sdk/lib/crt/time/time.cmake
@@ -0,0 +1,41 @@
+
+list(APPEND CRT_TIME_SOURCE
+    time/asctime.c
+    time/clock.c
+    time/ctime32.c
+    time/ctime64.c
+    time/ctime.c
+    time/difftime32.c
+    time/difftime64.c
+    time/difftime.c
+    time/ftime32.c
+    time/ftime64.c
+    time/ftime.c
+    time/futime32.c
+    time/futime64.c
+    time/futime.c
+    time/gmtime.c
+    time/localtime32.c
+    time/localtime64.c
+    time/localtime.c
+    time/mktime.c
+    time/strdate.c
+    time/strftime.c
+    time/strtime.c
+    time/time32.c
+    time/time64.c
+    time/time.c
+    time/timezone.c
+    time/utime32.c
+    time/utime64.c
+    time/utime.c
+    time/wasctime.c
+    time/wctime32.c
+    time/wctime64.c
+    time/wctime.c
+    time/wstrdate.c
+    time/wstrtime.c
+    time/wutime32.c
+    time/wutime64.c
+    time/wutime.c
+)
diff --git a/sdk/lib/crt/wine/wine.cmake b/sdk/lib/crt/wine/wine.cmake
new file mode 100644
index 00000000000..6a4346d64e3
--- /dev/null
+++ b/sdk/lib/crt/wine/wine.cmake
@@ -0,0 +1,26 @@
+
+list(APPEND CRT_WINE_SOURCE
+    wine/cpp.c
+    wine/except.c
+    wine/heap.c
+    wine/undname.c
+)
+
+if(ARCH STREQUAL "i386")
+    list(APPEND CRT_WINE_SOURCE
+        wine/except_i386.c
+    )
+elseif(ARCH STREQUAL "amd64")
+    list(APPEND CRT_WINE_SOURCE
+        wine/except_x86_64.c
+    )
+elseif(ARCH STREQUAL "arm")
+    list(APPEND CRT_WINE_SOURCE
+        wine/except_arm.c
+    )
+endif()
+
+# includes for wine code
+include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
+
+#set_source_files_properties(${CRT_WINE_SOURCE} PROPERTIES INCLUDE_DIRECTORIES)
diff --git a/sdk/lib/crt/wstring/wstring.cmake 
b/sdk/lib/crt/wstring/wstring.cmake
new file mode 100644
index 00000000000..e636367cf11
--- /dev/null
+++ b/sdk/lib/crt/wstring/wstring.cmake
@@ -0,0 +1,17 @@
+
+list(APPEND LIBCNTPR_WSTRING_SOURCE
+    wstring/wcsicmp.c
+    wstring/wcslwr.c
+    wstring/wcsnicmp.c
+    wstring/wcsupr.c
+    wstring/wcscspn.c
+    wstring/wcsspn.c
+    wstring/wcsstr.c
+)
+
+list(APPEND CRT_WSTRING_SOURCE
+    ${LIBCNTPR_WSTRING_SOURCE}
+    wstring/wcscoll.c
+    wstring/wcstok.c
+    wstring/wcsxfrm.c
+)

Reply via email to