Author: jgardou
Date: Sat Sep  3 17:48:57 2011
New Revision: 53553

URL: http://svn.reactos.org/svn/reactos?rev=53553&view=rev
Log:
[CMAKE]
- merge set_module_type function into the global CMakeMacros.cmake file, 
leaving compiler particular bits to set_module_type_toolchain function.
- Add the ENTRYPOINT and BASEADDRESS options to this function. Not used yet

Modified:
    trunk/reactos/cmake/CMakeMacros.cmake
    trunk/reactos/cmake/compilerflags.cmake
    trunk/reactos/cmake/gcc.cmake
    trunk/reactos/cmake/msvc.cmake

Modified: trunk/reactos/cmake/CMakeMacros.cmake
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/CMakeMacros.cmake?rev=53553&r1=53552&r2=53553&view=diff
==============================================================================
--- trunk/reactos/cmake/CMakeMacros.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/CMakeMacros.cmake [iso-8859-1] Sat Sep  3 17:48:57 2011
@@ -239,3 +239,96 @@
         add_dependency_edge(${_module} ${LIB})
     endforeach()
 endfunction()
+
+function(set_module_type MODULE TYPE)
+    cmake_parse_arguments(__module "" "IMAGEBASE" "ENTRYPOINT" ${ARGN})
+    
+    # Set subsystem. Also take this as an occasion
+    # to error out if someone gave a non existing type
+    if((${TYPE} STREQUAL nativecui) OR (${TYPE} STREQUAL nativedll) OR 
(${TYPE} STREQUAL kernelmodedriver))
+        set(__subsystem native)
+    elseif(${TYPE} STREQUAL win32cui)
+        set(__subsystem console)
+    elseif(${TYPE} STREQUAL win32gui)
+        set(__subsystem windows)
+    elseif(NOT ((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx) OR 
(${TYPE} STREQUAL cpl)))
+        message(FATAL_ERROR "Unknown type ${TYPE} for module ${MODULE}")
+    endif()
+    
+    if(DEFINED __subsystem)
+        set_subsystem(${MODULE} ${__subsystem})
+    endif()
+    
+    if(__module_UNPARSED_ARGUMENTS)
+        message(STATUS ${__module_UNPARSED_ARGUMENTS})
+    endif()
+    
+    # set entry point
+    if(__module_ENTRYPOINT)
+        list(GET __module_ENTRYPOINT 0 __entrypoint)
+        list(LENGTH __module_ENTRYPOINT __length)
+        if(${__length} EQUAL 2)
+            list(GET __module_ENTRYPOINT 1 __entrystack)
+        elseif(NOT ${__length} EQUAL 1)
+            message(FATAL_ERROR "Wrong arguments for ENTRYPOINT parameter of 
set_module_type : ${__module_ENTRYPOINT}")
+        endif()
+        unset(__length)
+    elseif(${TYPE} STREQUAL nativecui)
+        set(__entrypoint NtProcessStartup)
+        set(__entrystack 4)
+    elseif((${TYPE} STREQUAL win32gui) OR (${TYPE} STREQUAL win32cui))
+        if(IS_UNICODE)
+            set(__entrypoint wWinMainCRTStartup)
+        else()
+            set(__entrypoint WinMainCRTStartup)
+        endif(IS_UNICODE)
+    elseif((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx)
+            OR (${TYPE} STREQUAL cpl))
+        set(__entrypoint DllMainCRTStartup)
+        set(__entrystack 12)
+    elseif(${TYPE} STREQUAL kernelmodedriver)
+        set(__entrypoint DriverEntry)
+        set(__entrystack 8)
+    elseif(${TYPE} STREQUAL nativedll)
+        set(__entrypoint DllMain)
+        set(__entrystack 12)
+    endif()
+    
+    if(DEFINED __entrypoint)
+        if(DEFINED __entrystack)
+            set_entrypoint(${MODULE} ${__entrypoint} ${__entrystack})
+        else()
+            set_entrypoint(${MODULE} ${__entrypoint})
+        endif()
+    endif()
+    
+    #set base address
+    if(__module_IMAGEBASE)
+        set_image_base(${MODULE} __module_IMAGEBASE)
+    elseif(${TYPE} STREQUAL win32dll)
+        if(DEFINED baseaddress_${MODULE})
+            set_image_base(${MODULE} ${baseaddress_${MODULE}})
+        else()
+            message(STATUS "${MODULE} has no base address")
+        endif()
+    elseif(${TYPE} STREQUAL kernelmodedriver)
+        set_image_base(${MODULE} 0x00010000)
+    endif()
+    
+    # Now do some stuff which is specific to each type 
+    if(${TYPE} STREQUAL kernelmodedriver)
+        add_dependencies(${MODULE} bugcodes)
+        set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
+    endif()
+    
+    if(${TYPE} STREQUAL win32ocx)
+        set_target_properties(${MODULE} PROPERTIES SUFFIX ".ocx")
+    endif()
+    
+    if(${TYPE} STREQUAL cpl)
+        set_target_properties(${MODULE} PROPERTIES SUFFIX ".cpl")
+    endif()
+    
+    # do compiler specific stuff
+    set_module_type_toolchain(${MODULE} ${TYPE})
+endfunction()

Modified: trunk/reactos/cmake/compilerflags.cmake
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/compilerflags.cmake?rev=53553&r1=53552&r2=53553&view=diff
==============================================================================
--- trunk/reactos/cmake/compilerflags.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/compilerflags.cmake [iso-8859-1] Sat Sep  3 17:48:57 
2011
@@ -96,3 +96,14 @@
    add_definitions(-DUNICODE -D_UNICODE)
    set(IS_UNICODE 1)
 endmacro()
+
+function(add_compiler_flags_target __module)
+    get_target_property(__flags ${__module} COMPILE_FLAGS)
+    if(NOT __flags)
+        set(__flags "")
+    endif()
+    foreach(flag ${ARGN})
+        set(__flags "${__flags} ${flag}")
+    endforeach()
+    set_target_properties(${__module} PROPERTIES COMPILE_FLAGS ${__flags})
+endfunction()

Modified: trunk/reactos/cmake/gcc.cmake
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/gcc.cmake?rev=53553&r1=53552&r2=53553&view=diff
==============================================================================
--- trunk/reactos/cmake/gcc.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/gcc.cmake [iso-8859-1] Sat Sep  3 17:48:57 2011
@@ -120,55 +120,13 @@
     add_target_link_flags(${MODULE} "-Wl,--image-base,${IMAGE_BASE}")
 endfunction()
 
-function(set_module_type MODULE TYPE)
-
-    add_dependencies(${MODULE} psdk)
-    if(${IS_CPP})
+function(set_module_type_toolchain MODULE TYPE)
+    if(IS_CPP)
         target_link_libraries(${MODULE} stlport -lsupc++ -lgcc)
     endif()
 
-    if(${TYPE} MATCHES nativecui)
-        set_subsystem(${MODULE} native)
-        set_entrypoint(${MODULE} NtProcessStartup 4)
-    elseif(${TYPE} MATCHES win32gui)
-        set_subsystem(${MODULE} windows)
-        if(IS_UNICODE)
-            set_entrypoint(${MODULE} wWinMainCRTStartup)
-        else()
-            set_entrypoint(${MODULE} WinMainCRTStartup)
-        endif(IS_UNICODE)
-    elseif(${TYPE} MATCHES win32cui)
-        set_subsystem(${MODULE} console)
-        if(IS_UNICODE)
-            set_entrypoint(${MODULE} wmainCRTStartup)
-        else()
-            set_entrypoint(${MODULE} mainCRTStartup)
-        endif(IS_UNICODE)
-    elseif(${TYPE} MATCHES win32dll)
-        set_entrypoint(${MODULE} DllMainCRTStartup 12)
-        if(DEFINED baseaddress_${MODULE})
-            set_image_base(${MODULE} ${baseaddress_${MODULE}})
-        else()
-            message(STATUS "${MODULE} has no base address")
-        endif()
-    elseif(${TYPE} MATCHES win32ocx)
-        set_entrypoint(${MODULE} DllMainCRTStartup 12)
-        set_target_properties(${MODULE} PROPERTIES SUFFIX ".ocx")
-    elseif(${TYPE} MATCHES cpl)
-        set_entrypoint(${MODULE} DllMainCRTStartup 12)
-        set_target_properties(${MODULE} PROPERTIES SUFFIX ".cpl")
-    elseif(${TYPE} MATCHES kernelmodedriver)
+    if(${TYPE} STREQUAL kernelmodedriver)
         add_target_link_flags(${MODULE} "-Wl,--exclude-all-symbols 
-Wl,-file-alignment=0x1000 -Wl,-section-alignment=0x1000")
-        set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
-        set_entrypoint(${MODULE} DriverEntry 8)
-        set_subsystem(${MODULE} native)
-        set_image_base(${MODULE} 0x00010000)
-        add_dependencies(${MODULE} bugcodes)
-    elseif(${TYPE} MATCHES nativedll)
-        set_subsystem(${MODULE} native)
-        set_entrypoint(${MODULE} DllMain 12)
-    else()
-        message(FATAL_ERROR "Unknown module type : ${TYPE}")
     endif()
 endfunction()
 

Modified: trunk/reactos/cmake/msvc.cmake
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/msvc.cmake?rev=53553&r1=53552&r2=53553&view=diff
==============================================================================
--- trunk/reactos/cmake/msvc.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/msvc.cmake [iso-8859-1] Sat Sep  3 17:48:57 2011
@@ -81,53 +81,11 @@
     add_target_link_flags(${MODULE} "/BASE:${IMAGE_BASE}")
 endfunction()
 
-function(set_module_type MODULE TYPE)
-    add_dependencies(${MODULE} psdk)
-    if(${TYPE} MATCHES nativecui)
-        set_subsystem(${MODULE} native)
-        set_entrypoint(${MODULE} NtProcessStartup 4)
-    elseif (${TYPE} MATCHES win32gui)
-        set_subsystem(${MODULE} windows)
-        if(IS_UNICODE)
-            set_entrypoint(${MODULE} wWinMainCRTStartup)
-        else()
-            set_entrypoint(${MODULE} WinMainCRTStartup)
-        endif(IS_UNICODE)
-    elseif (${TYPE} MATCHES win32cui)
-        set_subsystem(${MODULE} console)
-        if(IS_UNICODE)
-            set_entrypoint(${MODULE} wmainCRTStartup)
-        else()
-            set_entrypoint(${MODULE} mainCRTStartup)
-        endif(IS_UNICODE)
-    elseif(${TYPE} MATCHES win32dll)
-        # Need this only because mingw library is broken
-        set_entrypoint(${MODULE} DllMainCRTStartup 12)
-        if(DEFINED baseaddress_${MODULE})
-            set_image_base(${MODULE} ${baseaddress_${MODULE}})
-        else()
-            message(STATUS "${MODULE} has no base address")
-        endif()
+function(set_module_type_toolchain MODULE TYPE)
+    if((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx) OR (${TYPE} 
STREQUAL cpl))
         add_target_link_flags(${MODULE} "/DLL")
-    elseif(${TYPE} MATCHES win32ocx)
-        set_entrypoint(${MODULE} DllMainCRTStartup 12)
-        set_target_properties(${MODULE} PROPERTIES SUFFIX ".ocx")
-        add_target_link_flags(${MODULE} "/DLL")
-    elseif(${TYPE} MATCHES cpl)
-        set_entrypoint(${MODULE} DllMainCRTStartup 12)
-        set_target_properties(${MODULE} PROPERTIES SUFFIX ".cpl")
-        add_target_link_flags(${MODULE} "/DLL")
-    elseif(${TYPE} MATCHES kernelmodedriver)
-        set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
-        set_entrypoint(${MODULE} DriverEntry 8)
-        set_subsystem(${MODULE} native)
-        set_image_base(${MODULE} 0x00010000)
+    elseif(${TYPE} STREQUAL kernelmodedriver)
         add_target_link_flags(${MODULE} "/DRIVER")
-        add_dependencies(${MODULE} bugcodes)
-    elseif(${TYPE} MATCHES nativedll)
-        set_subsystem(${MODULE} native)
-    else()
-        message(FATAL_ERROR "Unknown module type : ${TYPE}")
     endif()
 endfunction()
 


Reply via email to