[CRT]
[reactos.git] / msc.cmake
1
2 if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86")
3 add_definitions(-D__i386__)
4 endif()
5
6 add_definitions(-Dinline=__inline)
7
8 if(NOT CMAKE_CROSSCOMPILING)
9
10
11
12 else()
13
14 add_definitions(/GS- /Zl /Zi)
15 add_definitions(-Dinline=__inline -D__STDC__=1)
16
17 set(CMAKE_RC_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
18
19
20 macro(set_entrypoint MODULE ENTRYPOINT)
21 if(${ENTRYPOINT} STREQUAL "0")
22 set(NEW_LINKER_FLAGS "/ENTRY:0")
23 else()
24 set(NEW_LINKER_FLAGS "/ENTRY:${ENTRYPOINT}")
25 endif()
26 get_target_property(LINKER_FLAGS ${MODULE} LINK_FLAGS)
27 if(LINKER_FLAGS)
28 set(NEW_LINKER_FLAGS "${LINKER_FLAGS} ${NEW_LINKER_FLAGS}")
29 endif()
30 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${NEW_LINKER_FLAGS})
31 endmacro()
32
33 macro(set_subsystem MODULE SUBSYSTEM)
34 set(NEW_LINKER_FLAGS "/subsystem:${SUBSYSTEM}")
35 get_target_property(LINKER_FLAGS ${MODULE} LINK_FLAGS)
36 if(LINKER_FLAGS)
37 set(NEW_LINKER_FLAGS "${LINKER_FLAGS} ${NEW_LINKER_FLAGS}")
38 endif()
39 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${NEW_LINKER_FLAGS})
40 endmacro()
41
42 macro(set_image_base MODULE IMAGE_BASE)
43 set(NEW_LINKER_FLAGS "/BASE:${IMAGE_BASE}")
44 get_target_property(LINKER_FLAGS ${MODULE} LINK_FLAGS)
45 if(LINKER_FLAGS)
46 set(NEW_LINKER_FLAGS "${LINKER_FLAGS} ${NEW_LINKER_FLAGS}")
47 endif()
48 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${NEW_LINKER_FLAGS})
49 endmacro()
50
51 macro(set_module_type MODULE TYPE)
52 add_dependencies(${MODULE} psdk buildno_header)
53 if(${TYPE} MATCHES nativecui)
54 set_subsystem(${MODULE} native)
55 add_importlibs(${MODULE} ntdll)
56 endif()
57 if (${TYPE} MATCHES win32gui)
58 set_subsystem(${MODULE} windows)
59 endif ()
60 if (${TYPE} MATCHES win32cui)
61 set_subsystem(${MODULE} console)
62 endif ()
63 endmacro()
64
65 macro(set_unicode)
66 add_definitions(-DUNICODE -D_UNICODE)
67 endmacro()
68
69 set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od")
70 set(CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od")
71
72 macro(set_rc_compiler)
73 # dummy, this workaround is only needed in mingw due to lack of RC support in cmake
74 endmacro()
75
76 #idl files support
77 set(IDL_COMPILER midl)
78 set(IDL_FLAGS /win32)
79 set(IDL_HEADER_ARG /h) #.h
80 set(IDL_TYPELIB_ARG /tlb) #.tlb
81 set(IDL_SERVER_ARG /sstub) #.c for stub server library
82 set(IDL_CLIENT_ARG /cstub) #.c for stub client library
83
84
85 macro(add_importlib_def _def_file)
86 get_filename_component(_name ${_def_file} NAME_WE)
87 add_custom_target(
88 lib${_name}
89 COMMAND LINK /LIB /MACHINE:X86 /DEF:${CMAKE_CURRENT_BINARY_DIR}/${_file}.def /OUT:${CMAKE_BINARY_DIR}/importlibs/lib${_name}.lib
90 DEPENDS ${_def_file}
91 )
92 endmacro()
93
94 macro(add_importlibs MODULE)
95 foreach(LIB ${ARGN})
96 target_link_libraries(${MODULE} ${CMAKE_BINARY_DIR}/importlibs/lib${LIB}.lib)
97 #add_dependencies(${MODULE} lib${LIB})
98 endforeach()
99 endmacro()
100
101 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/importlibs)
102
103 #pseh workaround
104 set(PSEH_LIB "")
105
106 endif()
107