[CMAKE - MSC]
[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(add_importlibs MODULE)
52 foreach(LIB ${ARGN})
53 target_link_libraries(${MODULE} ${LIB}.LIB)
54 endforeach()
55 endmacro()
56
57 macro(set_module_type MODULE TYPE)
58 add_dependencies(${MODULE} psdk buildno_header)
59 if(${TYPE} MATCHES nativecui)
60 set_subsystem(${MODULE} native)
61 add_importlibs(${MODULE} ntdll)
62 endif()
63 if (${TYPE} MATCHES win32gui)
64 set_subsystem(${MODULE} windows)
65 endif ()
66 if (${TYPE} MATCHES win32cui)
67 set_subsystem(${MODULE} console)
68 endif ()
69 endmacro()
70
71 macro(set_unicode)
72 add_definitions(-DUNICODE -D_UNICODE)
73 endmacro()
74
75 endif()
76
77 set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od")
78 set(CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od")
79
80 macro(set_rc_compiler)
81 # dummy, this workaround is only needed in mingw due to lack of RC support in cmake
82 endmacro()
83
84 #typelib support
85 macro(ADD_TYPELIB TARGET)
86 foreach(SOURCE ${ARGN})
87 get_filename_component(FILE ${SOURCE} NAME_WE)
88 set(OBJECT ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.tlb)
89 add_custom_command(OUTPUT ${OBJECT}
90 COMMAND midl /I ${REACTOS_SOURCE_DIR}/include/dxsdk /I . /I ${REACTOS_SOURCE_DIR}/include /I ${REACTOS_SOURCE_DIR}/include/psdk /win32 /tlb ${OBJECT} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE})
91 list(APPEND OBJECTS ${OBJECT})
92 endforeach()
93 add_custom_target(${TARGET} ALL DEPENDS ${OBJECTS})
94 endmacro()