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