Skip to content

Commit

Permalink
[UCRT] Add CMake files
Browse files Browse the repository at this point in the history
  • Loading branch information
tkreuzer committed Jan 16, 2025
1 parent ef440b9 commit 7bb1266
Show file tree
Hide file tree
Showing 21 changed files with 654 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions sdk/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
126 changes: 126 additions & 0 deletions sdk/lib/ucrt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 17 additions & 0 deletions sdk/lib/ucrt/conio/conio.cmake
Original file line number Diff line number Diff line change
@@ -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
)
42 changes: 42 additions & 0 deletions sdk/lib/ucrt/convert/convert.cmake
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions sdk/lib/ucrt/dll/dll.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

list(APPEND UCRT_DLL_SOURCES
dll/appcrt_dllmain.cpp
dll/empty.cpp
)
10 changes: 10 additions & 0 deletions sdk/lib/ucrt/env/env.cmake
Original file line number Diff line number Diff line change
@@ -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
)
13 changes: 13 additions & 0 deletions sdk/lib/ucrt/exec/exec.cmake
Original file line number Diff line number Diff line change
@@ -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
)
25 changes: 25 additions & 0 deletions sdk/lib/ucrt/filesystem/filesystem.cmake
Original file line number Diff line number Diff line change
@@ -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()
28 changes: 28 additions & 0 deletions sdk/lib/ucrt/heap/heap.cmake
Original file line number Diff line number Diff line change
@@ -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()
24 changes: 24 additions & 0 deletions sdk/lib/ucrt/initializers/initializers.cmake
Original file line number Diff line number Diff line change
@@ -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()
17 changes: 17 additions & 0 deletions sdk/lib/ucrt/internal/internal.cmake
Original file line number Diff line number Diff line change
@@ -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
)
25 changes: 25 additions & 0 deletions sdk/lib/ucrt/locale/locale.cmake
Original file line number Diff line number Diff line change
@@ -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
)
25 changes: 25 additions & 0 deletions sdk/lib/ucrt/lowio/lowio.cmake
Original file line number Diff line number Diff line change
@@ -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
)
Loading

0 comments on commit 7bb1266

Please sign in to comment.