[UCRT] Add CMake files

This commit is contained in:
Timo Kreuzer 2024-10-11 14:52:11 +03:00
parent ef440b9aef
commit 7bb12665d6
21 changed files with 654 additions and 1 deletions

View file

@ -256,7 +256,7 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to
elseif(ARCH STREQUAL "amd64")
# clang-cl defines this one for itself
if (NOT (MSVC AND CMAKE_C_COMPILER_ID STREQUAL "Clang"))
add_compile_definitions(_M_AMD64)
add_compile_definitions(_M_AMD64 _M_X64)
endif()
add_definitions(-D_AMD64_ -D__x86_64__ -D_WIN64)
elseif(ARCH STREQUAL "arm")

View file

@ -52,6 +52,7 @@ add_subdirectory(strmiids)
add_subdirectory(smlib)
add_subdirectory(tdilib)
add_subdirectory(tzlib)
add_subdirectory(ucrt)
add_subdirectory(udmihelp)
add_subdirectory(uuid)
add_subdirectory(wdmguid)

126
sdk/lib/ucrt/CMakeLists.txt Normal file
View file

@ -0,0 +1,126 @@
set(CMAKE_CXX_STANDARD 17)
# Replace the old CRT include directory with the UCRT include directory
get_property(INCLUDE_DIRS DIRECTORY . PROPERTY INCLUDE_DIRECTORIES)
list(REMOVE_ITEM INCLUDE_DIRS "${REACTOS_SOURCE_DIR}/sdk/include/crt")
set_property(DIRECTORY . PROPERTY INCLUDE_DIRECTORIES ${INCLUDE_DIRS})
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/ucrt)
if(MSVC)
# Disable warning C4083: expected ')'; found identifier '<warning identifier>'
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4083>)
# Disable warning C4189: 'cvt': local variable is initialized but not referenced
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4189>)
endif()
# Internal includes
include_directories(BEFORE inc)
if(${ARCH} STREQUAL "i386")
include_directories(inc/i386)
endif()
remove_definitions(-D_WIN32_WINNT=0x502 -DWINVER=0x502)
add_compile_definitions(
WINVER=0x600
_WIN32_WINNT=0x600
_UCRT
_CORECRT_BUILD
_CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
_GCC_NO_SAL_ATTRIIBUTES
CRTDLL
)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
CMAKE_C_COMPILER_ID STREQUAL "Clang")
# Silence GCC/Clang warnings
add_compile_options(
-Wno-unknown-warning-option
-Wno-unused-function
-Wno-unknown-pragmas
-Wno-builtin-declaration-mismatch
-Wno-parentheses
-Wno-unused-variable
-Wno-sign-compare
-Wno-enum-compare
-Wno-switch
-Wno-write-strings
-Wno-comment
-Wno-narrowing
-Wno-misleading-indentation
-Wno-missing-braces
-Wno-unused-value
-Wno-unused-local-typedef
-Wno-unused-function
-Wno-writable-strings
-Wno-microsoft-template
-Wno-switch
-Wno-ignored-pragmas
-Wno-empty-body
-Wno-tautological-constant-out-of-range-compare
-Wno-ignored-attributes
-Wno-uninitialized
)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-reorder>)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_definitions(
_lrotl=___lrotl
_rotl=___rotl
_rotl64=___rotl64
_lrotr=___lrotr
_rotr=___rotr
_rotr64=___rotr64
)
endif()
# Hack until we support globally defining _DEBUG
if(DBG)
add_compile_definitions(_DEBUG)
endif()
include(conio/conio.cmake)
include(convert/convert.cmake)
include(dll/dll.cmake)
include(env/env.cmake)
include(exec/exec.cmake)
include(filesystem/filesystem.cmake)
include(heap/heap.cmake)
include(initializers/initializers.cmake)
include(internal/internal.cmake)
include(locale/locale.cmake)
include(lowio/lowio.cmake)
include(mbstring/mbstring.cmake)
include(misc/misc.cmake)
include(startup/startup.cmake)
include(stdio/stdio.cmake)
include(stdlib/stdlib.cmake)
include(string/string.cmake)
include(time/time.cmake)
add_library(ucrt OBJECT
${UCRT_CONIO_SOURCES}
${UCRT_CONVERT_SOURCES}
${UCRT_DLL_SOURCES}
${UCRT_ENV_SOURCES}
${UCRT_EXEC_SOURCES}
${UCRT_FILESYSTEM_SOURCES}
${UCRT_HEAP_SOURCES}
${UCRT_INITIALIZERS_SOURCES}
${UCRT_INTERNAL_SOURCES}
${UCRT_LOCALE_SOURCES}
${UCRT_LOWIO_SOURCES}
${UCRT_MBSTRING_SOURCES}
${UCRT_MISC_SOURCES}
${UCRT_STARTUP_SOURCES}
${UCRT_STDIO_SOURCES}
${UCRT_STDLIB_SOURCES}
${UCRT_STRING_SOURCES}
${UCRT_TIME_SOURCES}
)
#target_link_libraries(ucrt pseh)
add_dependencies(ucrt psdk asm)

View file

@ -0,0 +1,17 @@
list(APPEND UCRT_CONIO_SOURCES
conio/cgets.cpp
conio/cgetws.cpp
conio/cprintf.cpp
conio/cputs.cpp
conio/cputws.cpp
conio/cscanf.cpp
conio/getch.cpp
conio/getwch.cpp
conio/initcon.cpp
conio/initconin.cpp
conio/pipe.cpp
conio/popen.cpp
conio/putch.cpp
conio/putwch.cpp
)

View file

@ -0,0 +1,42 @@
list(APPEND UCRT_CONVERT_SOURCES
convert/atof.cpp
convert/atoldbl.cpp
convert/atox.cpp
convert/c16rtomb.cpp
convert/c32rtomb.cpp
convert/cfout.cpp
convert/common_utf8.cpp
convert/cvt.cpp
convert/fcvt.cpp
convert/fp_flags.cpp
convert/gcvt.cpp
convert/isctype.cpp
convert/ismbstr.cpp
convert/iswctype.cpp
convert/mblen.cpp
convert/mbrtoc16.cpp
convert/mbrtoc32.cpp
convert/mbrtowc.cpp
convert/mbstowcs.cpp
convert/mbtowc.cpp
convert/strtod.cpp
convert/strtox.cpp
convert/swab.cpp
convert/tolower_toupper.cpp
convert/towlower.cpp
convert/towupper.cpp
convert/wcrtomb.cpp
convert/wcstombs.cpp
convert/wctomb.cpp
convert/wctrans.cpp
convert/wctype.cpp
convert/xtoa.cpp
convert/_ctype.cpp
convert/_fptostr.cpp
convert/_mbslen.cpp
convert/_wctype.cpp
)
# All multibyte string functions require the _MBCS macro to be defined
set_source_files_properties(convert/ismbstr.cpp PROPERTIES COMPILE_DEFINITIONS _MBCS)

View file

@ -0,0 +1,5 @@
list(APPEND UCRT_DLL_SOURCES
dll/appcrt_dllmain.cpp
dll/empty.cpp
)

10
sdk/lib/ucrt/env/env.cmake vendored Normal file
View file

@ -0,0 +1,10 @@
list(APPEND UCRT_ENV_SOURCES
env/environment_initialization.cpp
env/getenv.cpp
env/getpath.cpp
env/get_environment_from_os.cpp
env/putenv.cpp
env/searchenv.cpp
env/setenv.cpp
)

View file

@ -0,0 +1,13 @@
list(APPEND UCRT_EXEC_SOURCES
exec/cenvarg.cpp
exec/exec.cmake
exec/getproc.cpp
exec/loaddll.cpp
exec/spawnl.cpp
exec/spawnlp.cpp
exec/spawnv.cpp
exec/spawnvp.cpp
exec/system.cpp
exec/wait.cpp
)

View file

@ -0,0 +1,25 @@
list(APPEND UCRT_FILESYSTEM_SOURCES
filesystem/access.cpp
filesystem/chmod.cpp
filesystem/findfile.cpp
filesystem/fullpath.cpp
filesystem/makepath.cpp
filesystem/mkdir.cpp
filesystem/rename.cpp
filesystem/rmdir.cpp
filesystem/splitpath.cpp
filesystem/stat.cpp
filesystem/unlink.cpp
filesystem/waccess.cpp
filesystem/wchmod.cpp
filesystem/wmkdir.cpp
filesystem/wrename.cpp
filesystem/wrmdir.cpp
filesystem/wunlink.cpp
)
if(MSVC)
# Disable warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
set_source_files_properties(filesystem/splitpath.cpp PROPERTIES COMPILE_FLAGS "/wd4838")
endif()

View file

@ -0,0 +1,28 @@
list(APPEND UCRT_HEAP_SOURCES
heap/align.cpp
heap/calloc.cpp
heap/calloc_base.cpp
heap/expand.cpp
heap/free.cpp
heap/free_base.cpp
heap/heapchk.cpp
heap/heapmin.cpp
heap/heapwalk.cpp
heap/heap_handle.cpp
heap/malloc.cpp
heap/malloc_base.cpp
heap/msize.cpp
heap/new_handler.cpp
heap/new_mode.cpp
heap/realloc.cpp
heap/realloc_base.cpp
heap/recalloc.cpp
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND UCRT_HEAP_SOURCES
heap/debug_heap.cpp
heap/debug_heap_hook.cpp
)
endif()

View file

@ -0,0 +1,24 @@
list(APPEND UCRT_INITIALIZERS_SOURCES
initializers/clock_initializer.cpp
initializers/console_input_initializer.cpp
initializers/console_output_initializer.cpp
initializers/fmode_initializer.cpp
initializers/locale_initializer.cpp
initializers/multibyte_initializer.cpp
initializers/stdio_initializer.cpp
initializers/timeset_initializer.cpp
initializers/tmpfile_initializer.cpp
)
if(${ARCH} STREQUAL "i386")
list(APPEND UCRT_INITIALIZERS_SOURCES
initializers/i386/sse2_initializer.cpp
)
endif()
if(${ARCH} STREQUAL "amd64" OR ${ARCH} STREQUAL "arm64")
list(APPEND UCRT_INITIALIZERS_SOURCES
initializers/fma3_initializer.cpp
)
endif()

View file

@ -0,0 +1,17 @@
list(APPEND UCRT_INTERNAL_SOURCES
internal/CreateProcessA.cpp
internal/GetModuleFileNameA.cpp
internal/initialization.cpp
internal/LoadLibraryExA.cpp
internal/locks.cpp
internal/OutputDebugStringA.cpp
internal/peb_access.cpp
internal/per_thread_data.cpp
internal/report_runtime_error.cpp
internal/SetCurrentDirectoryA.cpp
internal/SetEnvironmentVariableA.cpp
internal/shared_initialization.cpp
internal/winapi_thunks.cpp
internal/win_policies.cpp
)

View file

@ -0,0 +1,25 @@
list(APPEND UCRT_LOCALE_SOURCES
locale/CompareStringA.cpp
locale/CompareStringW.cpp
locale/ctype.cpp
locale/GetLocaleInfoA.cpp
locale/getqloc_downlevel.cpp
locale/GetStringTypeA.cpp
locale/get_qualified_locale.cpp
locale/glstatus.cpp
locale/initctype.cpp
locale/initmon.cpp
locale/initnum.cpp
locale/inittime.cpp
locale/lcidtoname_downlevel.cpp
locale/LCMapStringA.cpp
locale/LCMapStringW.cpp
locale/lconv_unsigned_char_initialization.cpp
locale/localeconv.cpp
locale/locale_refcounting.cpp
locale/locale_update.cpp
locale/nlsdata.cpp
locale/setlocale.cpp
locale/wsetlocale.cpp
)

View file

@ -0,0 +1,25 @@
list(APPEND UCRT_LOWIO_SOURCES
lowio/chsize.cpp
lowio/close.cpp
lowio/commit.cpp
lowio/creat.cpp
lowio/dup.cpp
lowio/dup2.cpp
lowio/eof.cpp
lowio/filelength.cpp
lowio/ioinit.cpp
lowio/isatty.cpp
lowio/locking.cpp
lowio/lseek.cpp
lowio/mktemp.cpp
lowio/open.cpp
lowio/osfinfo.cpp
lowio/read.cpp
lowio/setmode.cpp
lowio/tell.cpp
lowio/telli64.cpp
lowio/txtmode.cpp
lowio/umask.cpp
lowio/write.cpp
)

View file

@ -0,0 +1,93 @@
list(APPEND UCRT_MBSTRING_SOURCES
mbstring/ismbalnm.cpp
mbstring/ismbalph.cpp
mbstring/ismbbyte.cpp
mbstring/ismbdgt.cpp
mbstring/ismbgrph.cpp
mbstring/ismbknj.cpp
mbstring/ismblgl.cpp
mbstring/ismblwr.cpp
mbstring/ismbprn.cpp
mbstring/ismbpunc.cpp
mbstring/ismbsle.cpp
mbstring/ismbspc.cpp
mbstring/ismbupr.cpp
mbstring/mbbtype.cpp
mbstring/mbccpy.cpp
mbstring/mbccpy_s.cpp
mbstring/mbccpy_s_l.cpp
mbstring/mbclen.cpp
mbstring/mbclevel.cpp
mbstring/mbctype.cpp
mbstring/mbsbtype.cpp
mbstring/mbscat_s.cpp
mbstring/mbscat_s_l.cpp
mbstring/mbschr.cpp
mbstring/mbscmp.cpp
mbstring/mbscoll.cpp
mbstring/mbscpy_s.cpp
mbstring/mbscpy_s_l.cpp
mbstring/mbscspn.cpp
mbstring/mbsdec.cpp
mbstring/mbsicmp.cpp
mbstring/mbsicoll.cpp
mbstring/mbsinc.cpp
mbstring/mbslen.cpp
mbstring/mbslen_s.cpp
mbstring/mbslwr.cpp
mbstring/mbsnbcat.cpp
mbstring/mbsnbcat_s.cpp
mbstring/mbsnbcat_s_l.cpp
mbstring/mbsnbcmp.cpp
mbstring/mbsnbcnt.cpp
mbstring/mbsnbcol.cpp
mbstring/mbsnbcpy.cpp
mbstring/mbsnbcpy_s.cpp
mbstring/mbsnbcpy_s_l.cpp
mbstring/mbsnbicm.cpp
mbstring/mbsnbico.cpp
mbstring/mbsnbset.cpp
mbstring/mbsnbset_s.cpp
mbstring/mbsnbset_s_l.cpp
mbstring/mbsncat.cpp
mbstring/mbsncat_s.cpp
mbstring/mbsncat_s.inl
mbstring/mbsncat_s_l.cpp
mbstring/mbsnccnt.cpp
mbstring/mbsncmp.cpp
mbstring/mbsncoll.cpp
mbstring/mbsncpy.cpp
mbstring/mbsncpy_s.cpp
mbstring/mbsncpy_s.inl
mbstring/mbsncpy_s_l.cpp
mbstring/mbsnextc.cpp
mbstring/mbsnicmp.cpp
mbstring/mbsnicol.cpp
mbstring/mbsninc.cpp
mbstring/mbsnset.cpp
mbstring/mbsnset_s.cpp
mbstring/mbsnset_s.inl
mbstring/mbsnset_s_l.cpp
mbstring/mbspbrk.cpp
mbstring/mbsrchr.cpp
mbstring/mbsrev.cpp
mbstring/mbsset.cpp
mbstring/mbsset_s.cpp
mbstring/mbsset_s_l.cpp
mbstring/mbsspn.cpp
mbstring/mbsspnp.cpp
mbstring/mbsstr.cpp
mbstring/mbstok.cpp
mbstring/mbstok_s.cpp
mbstring/mbsupr.cpp
mbstring/mbtohira.cpp
mbstring/mbtokata.cpp
mbstring/mbtolwr.cpp
mbstring/mbtoupr.cpp
mbstring/tojisjms.cpp
mbstring/tombbmbc.cpp
)
# All multibyte string functions require the _MBCS macro to be defined
set_source_files_properties(${UCRT_MBSTRING_SOURCES} PROPERTIES COMPILE_DEFINITIONS _MBCS)

View file

@ -0,0 +1,34 @@
list(APPEND UCRT_MISC_SOURCES
misc/chdir.cpp
misc/crtmbox.cpp
misc/drive.cpp
misc/drivemap.cpp
misc/drivfree.cpp
misc/errno.cpp
misc/exception_filter.cpp
misc/getcwd.cpp
misc/getpid.cpp
misc/invalid_parameter.cpp
misc/is_wctype.cpp
misc/perror.cpp
misc/resetstk.cpp
misc/seterrm.cpp
misc/set_error_mode.cpp
misc/signal.cpp
misc/slbeep.cpp
misc/strerror.cpp
misc/syserr.cpp
misc/systime.cpp
misc/terminate.cpp
misc/wperror.cpp
misc/_strerr.cpp
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND UCRT_MISC_SOURCES
misc/dbgrpt.cpp
misc/dbgrptt.cpp
misc/debug_fill_threshold.cpp
)
endif()

View file

@ -0,0 +1,13 @@
list(APPEND UCRT_STARTUP_SOURCES
startup/abort.cpp
startup/argv_data.cpp
startup/argv_parsing.cpp
startup/argv_wildcards.cpp
startup/argv_winmain.cpp
startup/assert.cpp
startup/exit.cpp
startup/initterm.cpp
startup/onexit.cpp
startup/thread.cpp
)

View file

@ -0,0 +1,52 @@
list(APPEND UCRT_STDIO_SOURCES
stdio/clearerr.cpp
stdio/closeall.cpp
stdio/fclose.cpp
stdio/fdopen.cpp
stdio/feoferr.cpp
stdio/fflush.cpp
stdio/fgetc.cpp
stdio/fgetpos.cpp
stdio/fgets.cpp
stdio/fgetwc.cpp
stdio/fileno.cpp
stdio/fopen.cpp
stdio/fputc.cpp
stdio/fputs.cpp
stdio/fputwc.cpp
stdio/fputws.cpp
stdio/fread.cpp
stdio/freopen.cpp
stdio/fseek.cpp
stdio/fsetpos.cpp
stdio/ftell.cpp
stdio/fwrite.cpp
stdio/gets.cpp
stdio/gettemppath.cpp
stdio/getw.cpp
stdio/input.cpp
stdio/ncommode.cpp
stdio/openfile.cpp
stdio/output.cpp
stdio/printf_count_output.cpp
stdio/puts.cpp
stdio/putw.cpp
stdio/putws.cpp
stdio/rewind.cpp
stdio/rmtmp.cpp
stdio/setbuf.cpp
stdio/setmaxf.cpp
stdio/setvbuf.cpp
stdio/stream.cpp
stdio/tempnam.cpp
stdio/tmpfile.cpp
stdio/ungetc.cpp
stdio/ungetwc.cpp
stdio/_filbuf.cpp
stdio/_file.cpp
stdio/_flsbuf.cpp
stdio/_freebuf.cpp
stdio/_getbuf.cpp
stdio/_sftbuf.cpp
)

View file

@ -0,0 +1,24 @@
list(APPEND UCRT_STDLIB_SOURCES
stdlib/abs.cpp
stdlib/bsearch.cpp
stdlib/bsearch_s.cpp
stdlib/byteswap.cpp
stdlib/div.cpp
stdlib/imaxabs.cpp
stdlib/imaxdiv.cpp
stdlib/labs.cpp
stdlib/ldiv.cpp
stdlib/lfind.cpp
stdlib/lfind_s.cpp
stdlib/llabs.cpp
stdlib/lldiv.cpp
stdlib/lsearch.cpp
stdlib/lsearch_s.cpp
stdlib/qsort.cpp
stdlib/qsort_s.cpp
stdlib/rand.cpp
stdlib/rand_s.cpp
stdlib/rotl.cpp
stdlib/rotr.cpp
)

View file

@ -0,0 +1,58 @@
list(APPEND UCRT_STRING_SOURCES
string/memcpy_s.cpp
string/memicmp.cpp
string/strcat_s.cpp
string/strcoll.cpp
string/strcpy_s.cpp
string/strdup.cpp
string/stricmp.cpp
string/stricoll.cpp
string/strlwr.cpp
string/strncat_s.cpp
string/strncnt.cpp
string/strncoll.cpp
string/strncpy_s.cpp
string/strnicmp.cpp
string/strnicol.cpp
string/strnlen.cpp
string/strnset_s.cpp
string/strset_s.cpp
string/strtok.cpp
string/strtok_s.cpp
string/strupr.cpp
string/strxfrm.cpp
string/wcscat.cpp
string/wcscat_s.cpp
string/wcscmp.cpp
string/wcscoll.cpp
string/wcscpy.cpp
string/wcscpy_s.cpp
string/wcscspn.cpp
string/wcsdup.cpp
string/wcsicmp.cpp
string/wcsicoll.cpp
string/wcslwr.cpp
string/wcsncat.cpp
string/wcsncat_s.cpp
string/wcsncmp.cpp
string/wcsncnt.cpp
string/wcsncoll.cpp
string/wcsncpy.cpp
string/wcsncpy_s.cpp
string/wcsnicmp.cpp
string/wcsnicol.cpp
string/wcsnset.cpp
string/wcsnset_s.cpp
string/wcspbrk.cpp
string/wcsrev.cpp
string/wcsset.cpp
string/wcsset_s.cpp
string/wcsspn.cpp
string/wcstok.cpp
string/wcstok_s.cpp
string/wcsupr.cpp
string/wcsxfrm.cpp
string/wmemcpy_s.cpp
string/wmemmove_s.cpp
)

View file

@ -0,0 +1,21 @@
list(APPEND UCRT_TIME_SOURCES
time/asctime.cpp
time/clock.cpp
time/ctime.cpp
time/days.cpp
time/difftime.cpp
time/ftime.cpp
time/gmtime.cpp
time/localtime.cpp
time/loctotime.cpp
time/mktime.cpp
time/strdate.cpp
time/strftime.cpp
time/strtime.cpp
time/time.cpp
time/timeset.cpp
time/tzset.cpp
time/utime.cpp
time/wcsftime.cpp
)