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