mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:03:00 +00:00
[CMAKE] Use an INTERFACE library to perform the msvcrt <-> msvcrtex binding
This commit is contained in:
parent
bada20a361
commit
23e04ae1ee
3 changed files with 14 additions and 9 deletions
|
@ -1,6 +1,14 @@
|
||||||
|
|
||||||
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/crt/include)
|
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/crt/include)
|
||||||
spec2def(msvcrt.dll msvcrt.spec ADD_IMPORTLIB)
|
spec2def(msvcrt.dll msvcrt.spec)
|
||||||
|
|
||||||
|
# The msvcrt <-> msvcrtex trick
|
||||||
|
generate_import_lib(libmsvcrt_real msvcrt.dll msvcrt.spec)
|
||||||
|
add_library(libmsvcrt INTERFACE)
|
||||||
|
target_compile_definitions(libmsvcrt INTERFACE _DLL __USE_CRTIMP)
|
||||||
|
# if the linked module is one of win32gui;win32cui;win32dll;win32ocx;cpl link it with msvcrtex, which itself is linked to libmsvcrt_real
|
||||||
|
# Otherwise, just link to libmsvcrt_real
|
||||||
|
target_link_libraries(libmsvcrt INTERFACE "$<IF:$<IN_LIST:$<TARGET_PROPERTY:REACTOS_MODULE_TYPE>,win32gui;win32cui;win32dll;win32ocx;cpl>,msvcrtex,libmsvcrt_real>")
|
||||||
|
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DUSE_MSVCRT_PREFIX
|
-DUSE_MSVCRT_PREFIX
|
||||||
|
@ -26,8 +34,8 @@ target_link_libraries(msvcrt crt wine ${PSEH_LIB})
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# export of deleting destructor "name"
|
# export of deleting destructor "name"
|
||||||
add_target_link_flags(msvcrt "/ignore:4102")
|
target_link_options(msvcrt PRIVATE "/ignore:4102")
|
||||||
add_target_property(libmsvcrt STATIC_LIBRARY_FLAGS "/ignore:4102")
|
set_property(TARGET libmsvcrt_real APPEND PROPERTY STATIC_LIBRARY_OPTIONS "/ignore:4102")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_importlibs(msvcrt kernel32 ntdll)
|
add_importlibs(msvcrt kernel32 ntdll)
|
||||||
|
|
|
@ -531,13 +531,7 @@ endif()
|
||||||
function(add_importlibs _module)
|
function(add_importlibs _module)
|
||||||
add_dependency_node(${_module})
|
add_dependency_node(${_module})
|
||||||
foreach(LIB ${ARGN})
|
foreach(LIB ${ARGN})
|
||||||
if("${LIB}" MATCHES "msvcrt")
|
|
||||||
target_compile_definitions(${_module} PRIVATE _DLL __USE_CRTIMP)
|
|
||||||
# set_module_type might not have been called at this point, so use a generator expression
|
|
||||||
target_link_libraries(${_module} "$<$<IN_LIST:$<TARGET_PROPERTY:${_module},REACTOS_MODULE_TYPE>,win32gui;win32cui;win32dll;win32ocx;cpl>:msvcrtex>")
|
|
||||||
endif()
|
|
||||||
target_link_libraries(${_module} lib${LIB})
|
target_link_libraries(${_module} lib${LIB})
|
||||||
add_dependencies(${_module} lib${LIB})
|
|
||||||
add_dependency_edge(${_module} ${LIB})
|
add_dependency_edge(${_module} ${LIB})
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -96,6 +96,9 @@ add_asm_files(msvcrtex_asm ${MSVCRTEX_ASM_SOURCE})
|
||||||
add_library(msvcrtex ${MSVCRTEX_SOURCE} ${msvcrtex_asm})
|
add_library(msvcrtex ${MSVCRTEX_SOURCE} ${msvcrtex_asm})
|
||||||
target_compile_definitions(msvcrtex PRIVATE _DLL _MSVCRTEX_)
|
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(GCC OR CLANG)
|
if(GCC OR CLANG)
|
||||||
target_compile_options(msvcrtex PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-main>)
|
target_compile_options(msvcrtex PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-main>)
|
||||||
if(LTCG)
|
if(LTCG)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue