xref: /reactos/sdk/lib/crt/msvcrtex.cmake (revision 34586814)
1
2include_directories(include/internal/mingw-w64)
3
4list(APPEND MSVCRTEX_SOURCE
5    ${CRT_STARTUP_SOURCE}
6    math/sincos.c
7    misc/fltused.c
8    misc/isblank.c
9    misc/iswblank.c
10    misc/ofmt_stub.c
11    stdio/acrt_iob_func.c)
12
13if(DLL_EXPORT_VERSION LESS 0x600)
14    list(APPEND MSVCRTEX_SOURCE
15        misc/dbgrpt.cpp
16        stdlib/_invalid_parameter.c
17        stdlib/rand_s.c
18        wstring/mbrtowc.c
19        wstring/wcrtomb.c
20    )
21endif()
22
23if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
24    # Clang performs some optimizations requiring those funtions
25    list(APPEND MSVCRTEX_SOURCE
26        math/round.c
27        math/roundf.c
28        math/exp2.c
29        math/exp2f.c
30        )
31endif()
32
33if(ARCH STREQUAL "i386")
34    # Clang wants __aulldiv for its optimizations
35    list(APPEND MSVCRTEX_ASM_SOURCE
36        except/i386/chkstk_asm.s
37        except/i386/chkstk_ms.s
38        math/i386/alldiv_asm.s
39        math/i386/aulldiv_asm.s
40        )
41    if (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT MSVC)
42        list(APPEND MSVCRTEX_ASM_SOURCE
43            math/i386/ceilf.S
44            math/i386/floorf.S)
45        list(APPEND MSVCRTEX_SOURCE
46            math/i386/sqrtf.c)
47    endif()
48    if(MSVC AND DLL_EXPORT_VERSION LESS 0x600)
49        list(APPEND MSVCRTEX_ASM_SOURCE
50            except/i386/__CxxFrameHandler3.s
51            math/i386/ftoul2_legacy_asm.s)
52        list(APPEND MSVCRTEX_SOURCE
53            except/i386/CxxHandleV8Frame.c)
54    endif()
55elseif(ARCH STREQUAL "amd64")
56    list(APPEND MSVCRTEX_ASM_SOURCE
57        except/amd64/chkstk_ms.s)
58    if(MSVC AND DLL_EXPORT_VERSION LESS 0x600)
59        list(APPEND MSVCRTEX_ASM_SOURCE
60            except/amd64/__CxxFrameHandler3.s
61        )
62    endif()
63elseif(ARCH STREQUAL "arm")
64    list(APPEND MSVCRTEX_SOURCE
65        math/arm/__rt_sdiv.c
66        math/arm/__rt_sdiv64_worker.c
67        math/arm/__rt_udiv.c
68        math/arm/__rt_udiv64_worker.c
69        math/arm/__rt_div_worker.h
70        math/arm/__dtoi64.c
71        math/arm/__dtou64.c
72        math/arm/__stoi64.c
73        math/arm/__stou64.c
74        math/arm/__fto64.h
75        math/arm/__i64tod.c
76        math/arm/__u64tod.c
77        math/arm/__i64tos.c
78        math/arm/__u64tos.c
79        math/arm/__64tof.h
80    )
81    list(APPEND MSVCRTEX_ASM_SOURCE
82        except/arm/chkstk_asm.s
83        math/arm/__rt_sdiv64.s
84        math/arm/__rt_srsh.s
85        math/arm/__rt_udiv64.s
86    )
87endif()
88
89set_source_files_properties(${MSVCRTEX_ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_DLL;_MSVCRTEX_")
90add_asm_files(msvcrtex_asm ${MSVCRTEX_ASM_SOURCE})
91
92add_library(msvcrtex OBJECT ${MSVCRTEX_SOURCE} ${msvcrtex_asm})
93target_compile_definitions(msvcrtex PRIVATE _DLL _MSVCRTEX_)
94
95if(MSVC AND (ARCH STREQUAL "i386"))
96    # user32.dll needs this as a stand-alone object file
97    add_asm_files(ftol2_asm math/i386/ftol2_asm.s)
98    add_library(ftol2_sse OBJECT ${ftol2_asm})
99    target_compile_definitions(ftol2_sse PRIVATE $<TARGET_PROPERTY:msvcrtex,COMPILE_DEFINITIONS>)
100    set_target_properties(ftol2_sse PROPERTIES LINKER_LANGUAGE C)
101endif()
102
103
104if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
105    target_compile_options(msvcrtex PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-main>)
106    if(LTCG)
107        target_compile_options(msvcrtex PRIVATE -fno-lto)
108    endif()
109endif()
110
111set_source_files_properties(startup/crtdll.c PROPERTIES COMPILE_DEFINITIONS CRTDLL)
112set_source_files_properties(startup/crtexe.c
113                            startup/wcrtexe.c PROPERTIES COMPILE_DEFINITIONS _M_CEE_PURE)
114
115if(NOT MSVC)
116    target_link_libraries(msvcrtex oldnames)
117endif()
118
119add_dependencies(msvcrtex psdk asm)
120