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