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