[CMAKE] Turn import libs into regular C static libs

Embed msvcrtex into libmsvcrt

Idea taken from Thomas Faber
This commit is contained in:
Jérôme Gardou 2020-11-02 10:51:08 +01:00 committed by Jérôme Gardou
parent cad583967b
commit b96e88894a
7 changed files with 109 additions and 60 deletions

View file

@ -49,7 +49,6 @@ if(ARCH STREQUAL "i386")
list(APPEND MSVCRTEX_ASM_SOURCE
except/i386/chkstk_asm.s
except/i386/chkstk_ms.s
math/i386/ftol2_asm.s
math/i386/alldiv_asm.s)
list(APPEND MSVCRTEX_SOURCE
math/i386/ci.c
@ -102,11 +101,16 @@ endif()
set_source_files_properties(${MSVCRTEX_ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_DLL;_MSVCRTEX_")
add_asm_files(msvcrtex_asm ${MSVCRTEX_ASM_SOURCE})
add_library(msvcrtex ${MSVCRTEX_SOURCE} ${msvcrtex_asm})
add_library(msvcrtex OBJECT ${MSVCRTEX_SOURCE} ${msvcrtex_asm})
target_compile_definitions(msvcrtex PRIVATE _DLL _MSVCRTEX_)
# Link msvcrtex to the "real" msvcrt.dll library. See msvcrt.dll CMakeLists.txt to see what really happens here
target_link_libraries(msvcrtex libmsvcrt_real libkernel32)
if(MSVC AND (ARCH STREQUAL "i386"))
# user32.dll needs this as a stand-alone object file
add_asm_files(ftol2_asm math/i386/ftol2_asm.s)
add_library(ftol2_sse OBJECT ${ftol2_asm})
target_compile_definitions(ftol2_sse PRIVATE $<TARGET_PROPERTY:msvcrtex,COMPILE_DEFINITIONS>)
endif()
if(GCC OR CLANG)
target_compile_options(msvcrtex PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-main>)