[CMAKE]
[reactos.git] / gcc.cmake
index b8b4159..1819531 100644 (file)
--- a/gcc.cmake
+++ b/gcc.cmake
@@ -10,6 +10,7 @@ else()
 # Linking\r
 link_directories("${REACTOS_SOURCE_DIR}/importlibs" ${REACTOS_BINARY_DIR}/lib/3rdparty/mingw)\r
 set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")\r
+set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -lstdc++ -lsupc++ -lgcc -lmingwex -lmingw32 <LINK_LIBRARIES>")\r
 set(CMAKE_EXE_LINKER_FLAGS "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--kill-at -Wl,-T,${REACTOS_SOURCE_DIR}/global.lds")\r
 \r
 # Compiler Core\r
@@ -30,15 +31,25 @@ add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-e
 add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -fno-set-stack-executable -fno-optimize-sibling-calls)\r
 \r
 # C++ Flags\r
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")\r
+#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")\r
 \r
 # Macros\r
 macro(set_entrypoint MODULE ENTRYPOINT)\r
-  set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "-Wl,-entry,_${ENTRYPOINT}")\r
+    set(NEW_LINKER_FLAGS "-Wl,-entry,_${ENTRYPOINT}")\r
+    get_target_property(LINKER_FLAGS ${MODULE} LINK_FLAGS)\r
+    if(LINKER_FLAGS)\r
+        set(NEW_LINKER_FLAGS "${LINKER_FLAGS} ${NEW_LINKER_FLAGS}")\r
+    endif()\r
+    set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${NEW_LINKER_FLAGS})\r
 endmacro()\r
 \r
 macro(set_subsystem MODULE SUBSYSTEM)\r
-  set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "-Wl,--subsystem,${SUBSYSTEM}")\r
+    set(NEW_LINKER_FLAGS "-Wl,--subsystem,${SUBSYSTEM}")\r
+    get_target_property(LINKER_FLAGS ${MODULE} LINK_FLAGS)\r
+    if(LINKER_FLAGS)\r
+        set(NEW_LINKER_FLAGS "${LINKER_FLAGS} ${NEW_LINKER_FLAGS}")\r
+    endif()\r
+    set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${NEW_LINKER_FLAGS})\r
 endmacro()\r
 \r
 macro(add_importlibs MODULE)\r
@@ -48,20 +59,52 @@ macro(add_importlibs MODULE)
 endmacro()\r
 \r
 macro(set_module_type MODULE TYPE)\r
-  target_link_libraries(${MODULE} mingw_wmain mingw_common)\r
+\r
+  add_dependencies(${MODULE} builno_header psdk)\r
+  \r
   if(${TYPE} MATCHES nativecui)\r
     set_subsystem(${MODULE} native)\r
     set_entrypoint(${MODULE} NtProcessStartup@4)\r
   endif()\r
   if(${TYPE} MATCHES win32gui)\r
     set_subsystem(${MODULE} windows)\r
-    set_entrypoint(${MODULE} wWinMainCRTStartup)\r
+    set_entrypoint(${MODULE} WinMainCRTStartup)\r
   endif()\r
   if(${TYPE} MATCHES win32cui)\r
-    set_subsystem(${MODULE} windows)\r
+    set_subsystem(${MODULE} console)\r
     set_entrypoint(${MODULE} mainCRTStartup)\r
   endif()\r
+  if(${TYPE} MATCHES win32dll)\r
+    target_link_libraries(${MODULE} mingw_dllmain mingw_common)\r
+    set_entrypoint(${MODULE} DllMain@12)\r
+  endif()\r
 endmacro()\r
 \r
 endif()\r
 \r
+macro(set_unicode MODULE STATE)\r
+   if(${STATE} MATCHES yes)\r
+       add_definitions(-DUNICODE -D_UNICODE)\r
+       target_link_libraries(${MODULE} mingw_wmain)\r
+   else()\r
+       target_link_libraries(${MODULE} mingw_main)\r
+   endif()\r
+   \r
+  target_link_libraries(${MODULE} mingw_common)\r
+endmacro()\r
+\r
+# Workaround lack of mingw RC support in cmake\r
+macro(set_rc_compiler)\r
+    get_directory_property(defines COMPILE_DEFINITIONS)\r
+    get_directory_property(includes INCLUDE_DIRECTORIES)\r
+\r
+    foreach(arg ${defines})\r
+        set(result_defs "${result_defs} -D${arg}")\r
+    endforeach(arg ${defines})\r
+\r
+    foreach(arg ${includes})\r
+        set(result_incs "-I${arg} ${result_incs}")\r
+    endforeach(arg ${includes})\r
+\r
+    SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${result_defs} ${result_incs} -i <SOURCE> -O coff -o <OBJECT>")\r
+endmacro()\r