[CMAKE]
[reactos.git] / msc.cmake
index f6c0699..864eea0 100644 (file)
--- a/msc.cmake
+++ b/msc.cmake
@@ -1,12 +1,5 @@
 \r
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86")\r
-    add_definitions(-D__i386__)\r
-endif()\r
-\r
-add_definitions(-Dinline=__inline)\r
-\r
-if(CMAKE_CROSSCOMPILING)\r
-\r
+if(0) # Fixme redefinition warning\r
 if(OPTIMIZE STREQUAL "1")\r
     add_definitions(/O1)\r
 elseif(OPTIMIZE STREQUAL "2")\r
@@ -18,8 +11,9 @@ elseif(OPTIMIZE STREQUAL "4")
 elseif(OPTIMIZE STREQUAL "5")\r
     add_definitions(/GF /Gy /Ob2 /Os /Ox /GS-)\r
 endif()\r
+endif()\r
 \r
-add_definitions(/GS- /Zl /Zi)\r
+add_definitions(/X /GS- /Zl /Zi)\r
 add_definitions(-Dinline=__inline -D__STDC__=1)\r
 \r
 if(${_MACHINE_ARCH_FLAG} MATCHES X86)\r
@@ -28,6 +22,10 @@ if(${_MACHINE_ARCH_FLAG} MATCHES X86)
   set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")\r
 endif()\r
 \r
+if(${ARCH} MATCHES amd64)\r
+    add_definitions(-D__x86_64)\r
+endif()\r
+\r
 link_directories("${REACTOS_BINARY_DIR}/importlibs" ${REACTOS_BINARY_DIR}/lib/3rdparty/mingw)\r
 \r
 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>")\r
@@ -122,6 +120,7 @@ macro(set_module_type MODULE TYPE)
         set_image_base(${MODULE} 0x00010000)\r
         add_linkerflag(${MODULE} "/DRIVER")\r
         add_dependencies(${MODULE} bugcodes)\r
+        target_link_libraries(${MODULE} msvcsup)\r
     endif()\r
 endmacro()\r
 \r
@@ -137,30 +136,29 @@ macro(set_rc_compiler)
 # dummy, this workaround is only needed in mingw due to lack of RC support in cmake\r
 endmacro()\r
 \r
-#idl files support\r
-set(IDL_COMPILER midl)\r
-set(IDL_FLAGS /win32)\r
-set(IDL_HEADER_ARG /h) #.h\r
-set(IDL_TYPELIB_ARG /tlb) #.tlb\r
-set(IDL_SERVER_ARG /sstub) #.c for stub server library\r
-set(IDL_CLIENT_ARG /cstub) #.c for stub client library\r
-set(IDL_PROXY_ARG /proxy)\r
-set(IDL_DLLDATA_ARG /dlldata )\r
-\r
 # Thanks MS for creating a stupid linker\r
 macro(add_importlib_target _exports_file)\r
     get_filename_component(_name ${_exports_file} NAME_WE)\r
+    get_target_property(_suffix ${_name} SUFFIX)\r
+    if(${_suffix} STREQUAL "_suffix-NOTFOUND")\r
+        get_target_property(_type ${_name} TYPE)\r
+        if(${_type} MATCHES EXECUTABLE)\r
+            set(_suffix ".exe")\r
+        else()\r
+            set(_suffix ".dll")\r
+        endif()\r
+    endif()\r
 \r
     # Generate the asm stub file and the export def file\r
     add_custom_command(\r
         OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def\r
-        COMMAND native-spec2def -@ -r -d=${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def -l=${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}\r
+        COMMAND native-spec2def --ms --kill-at -r -n=${_name}${_suffix} -d=${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def -l=${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}\r
         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file})\r
 \r
     # Assemble the stub file\r
     add_custom_command(\r
         OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.obj\r
-        COMMAND ${CMAKE_ASM_COMPILER} /nologo /Fo${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.obj /c /Ta ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm\r
+        COMMAND ${CMAKE_ASM_COMPILER} /nologo /Cp /Fo${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.obj /c /Ta ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm\r
         DEPENDS "${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm")\r
 \r
     # Add neccessary importlibs for redirections\r
@@ -180,7 +178,7 @@ macro(add_importlib_target _exports_file)
     add_custom_target(\r
         lib${_name}\r
         DEPENDS ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.lib)\r
-    \r
+\r
     add_dependencies(lib${_name} asm ${_dependencies})\r
 endmacro()\r
 \r
@@ -195,31 +193,18 @@ macro(spec2def _dllname _spec_file)
     get_filename_component(_file ${_spec_file} NAME_WE)\r
     add_custom_command(\r
         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c\r
-        COMMAND native-spec2def -@ -n=${_dllname} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}\r
+        COMMAND native-spec2def --ms --kill-at -n=${_dllname} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}\r
         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file})\r
     set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c\r
         PROPERTIES GENERATED TRUE)\r
-    list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c)\r
-endmacro()\r
-\r
-# Optional 3rd parameter: dllname\r
-macro(set_export_spec _module _spec_file)\r
-    get_filename_component(_file ${_spec_file} NAME_WE)\r
-    if (${ARGC} GREATER 2)\r
-        set(_dllname ${ARGV2})\r
-    else()\r
-        set(_dllname ${_file}.dll)\r
-    endif()\r
-    spec2def(${_dllname} ${_spec_file})\r
 endmacro()\r
 \r
 macro(macro_mc FILE)\r
-    set(COMMAND_MC mc -r ${REACTOS_BINARY_DIR}/include/reactos -h ${REACTOS_BINARY_DIR}/include/reactos ${REACTOS_SOURCE_DIR}/include/reactos/mc/${FILE}.mc)\r
+    set(COMMAND_MC mc -r ${REACTOS_BINARY_DIR}/include/reactos -h ${REACTOS_BINARY_DIR}/include/reactos ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.mc)\r
 endmacro()\r
 \r
 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/importlibs)\r
 \r
 #pseh workaround\r
-set(PSEH_LIB "")\r
+set(PSEH_LIB "pseh")\r
 \r
-endif(CMAKE_CROSSCOMPILING)\r