Author: jgardou
Date: Tue Feb 21 14:32:05 2012
New Revision: 55776

URL: http://svn.reactos.org/svn/reactos?rev=55776&view=rev
Log:
[CMAKE]
 - generate 'real' libraries for import libraries
This way only the link step relies on them.
Should avoid rebuilding half of the tree next time Alex changes ntdll.spec
A relinking orgy is more than enough

Modified:
    trunk/reactos/cmake/CMakeMacros.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=55776&r1=55775&r2=55776&view=diff
==============================================================================
--- trunk/reactos/cmake/CMakeMacros.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/CMakeMacros.cmake [iso-8859-1] Tue Feb 21 14:32:05 2012
@@ -271,7 +271,7 @@
             add_target_compile_definitions(${_module} _DLL __USE_CRTIMP)
             target_link_libraries(${_module} msvcrtex)
         endif()
-        target_link_libraries(${_module} 
${CMAKE_BINARY_DIR}/importlibs/lib${LIB}${CMAKE_STATIC_LIBRARY_SUFFIX})
+        target_link_libraries(${_module} lib${LIB})
         add_dependencies(${_module} lib${LIB})
         add_dependency_edge(${_module} ${LIB})
     endforeach()

Modified: trunk/reactos/cmake/gcc.cmake
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/gcc.cmake?rev=55776&r1=55775&r2=55776&view=diff
==============================================================================
--- trunk/reactos/cmake/gcc.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/gcc.cmake [iso-8859-1] Tue Feb 21 14:32:05 2012
@@ -182,8 +182,7 @@
 
 function(add_delay_importlibs MODULE)
     foreach(LIB ${ARGN})
-        target_link_libraries(${MODULE} 
${CMAKE_BINARY_DIR}/importlibs/lib${LIB}_delayed.a)
-        add_dependencies(${MODULE} lib${LIB}_delayed)
+        target_link_libraries(${MODULE} lib${LIB}_delayed)
     endforeach()
     target_link_libraries(${MODULE} delayimp)
 endfunction()
@@ -192,50 +191,32 @@
     set(DECO_OPTION "-@")
 endif()
 
+# Cute little hack to produce import libs
+set(CMAKE_IMPLIB_CREATE_STATIC_LIBRARY "${CMAKE_DLLTOOL} --def <OBJECTS> 
--kill-at --output-lib=<TARGET>")
+set(CMAKE_IMPLIB_DELAYED_CREATE_STATIC_LIBRARY "${CMAKE_DLLTOOL} --def 
<OBJECTS> --kill-at --output-delaylib=<TARGET>")
 function(add_importlib_target _exports_file _implib_name)
-
     get_filename_component(_name ${_exports_file} NAME_WE)
     get_filename_component(_extension ${_exports_file} EXT)
 
     if(${_extension} STREQUAL ".spec")
 
-        # Normal importlib creation
+        # generate .def
         add_custom_command(
-            OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
+            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def
             COMMAND native-spec2def -n=${_implib_name} -a=${ARCH2} 
-d=${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def 
${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}
-            COMMAND ${CMAKE_DLLTOOL} --def 
${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def --kill-at 
--output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
             DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} 
native-spec2def)
-
-        # Delayed importlib creation
-        add_custom_command(
-            OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
-            COMMAND native-spec2def -n=${_implib_name} -a=${ARCH2} 
-d=${CMAKE_CURRENT_BINARY_DIR}/${_name}_delayed_implib.def 
${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}
-            COMMAND ${CMAKE_DLLTOOL} --def 
${CMAKE_CURRENT_BINARY_DIR}/${_name}_delayed_implib.def --kill-at 
--output-delaylib ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
-            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} 
native-spec2def)
-
-    elseif(${_extension} STREQUAL ".def")
-        message("Use of def files for import libs is deprecated: 
${_exports_file}")
-        add_custom_command(
-            OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
-            COMMAND ${CMAKE_DLLTOOL} --def 
${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} --kill-at 
--output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
-            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file})
-        add_custom_command(
-            OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
-            COMMAND ${CMAKE_DLLTOOL} --def 
${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} --kill-at --output-delaylib 
${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
-            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file})
+        
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def 
PROPERTIES EXTERNAL_OBJECT TRUE)
+        
+        #create normal importlib
+        add_library(lib${_name} STATIC EXCLUDE_FROM_ALL 
${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def)
+        set_target_properties(lib${_name} PROPERTIES LINKER_LANGUAGE "IMPLIB" 
PREFIX "")
+        
+        #create delayed importlib
+        add_library(lib${_name}_delayed STATIC EXCLUDE_FROM_ALL 
${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def)
+        set_target_properties(lib${_name}_delayed PROPERTIES LINKER_LANGUAGE 
"IMPLIB" PREFIX "")
     else()
         message(FATAL_ERROR "Unsupported exports file extension: 
${_extension}")
     endif()
-
-    # Normal importlib target
-    add_custom_target(
-        lib${_name}
-        DEPENDS ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a)
-    # Delayed importlib target
-    add_custom_target(
-        lib${_name}_delayed
-        DEPENDS ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a)
-
 endfunction()
 
 function(spec2def _dllname _spec_file)

Modified: trunk/reactos/cmake/msvc.cmake
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/msvc.cmake?rev=55776&r1=55775&r2=55776&view=diff
==============================================================================
--- trunk/reactos/cmake/msvc.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/msvc.cmake [iso-8859-1] Tue Feb 21 14:32:05 2012
@@ -131,6 +131,9 @@
     set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${rc_result_defs} 
/I${CMAKE_CURRENT_SOURCE_DIR} ${rc_result_incs} /fo <OBJECT> <SOURCE>" 
PARENT_SCOPE)
 endfunction()
 
+#define those for having real libraries
+set(CMAKE_IMPLIB_CREATE_STATIC_LIBRARY "LINK /LIB /NOLOGO <LINK_FLAGS> 
/OUT:<TARGET> <OBJECTS>")
+
 # Thanks MS for creating a stupid linker
 function(add_importlib_target _exports_file _implib_name)
 
@@ -138,43 +141,31 @@
 
     # Generate the asm stub file and the export def file
     add_custom_command(
-        OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm 
${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def
-        COMMAND native-spec2def --ms --kill-at -a=${SPEC2DEF_ARCH} --implib 
-n=${_implib_name} -d=${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def 
-l=${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm 
${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}
+        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib${_name}_stubs.asm 
${CMAKE_CURRENT_BINARY_DIR}/lib${_name}_exp.def
+        COMMAND native-spec2def --ms --kill-at -a=${SPEC2DEF_ARCH} --implib 
-n=${_implib_name} -d=${CMAKE_CURRENT_BINARY_DIR}/lib${_name}_exp.def 
-l=${CMAKE_CURRENT_BINARY_DIR}/lib${_name}_stubs.asm 
${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}
         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} native-spec2def)
-
-    # Assemble the stub file
-    add_custom_command(
-        OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.obj
-        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
-        DEPENDS "${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm")
-
-    # Add neccessary importlibs for redirections
-    set(_libraries "")
-    set(_dependencies "")
-    foreach(_lib ${ARGN})
-        list(APPEND _libraries "${CMAKE_BINARY_DIR}/importlibs/${_lib}.lib")
-        list(APPEND _dependencies ${_lib})
-    endforeach()
-
-    # Build the importlib
-    add_custom_command(
-        OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.lib
-        COMMAND LINK /LIB /NOLOGO 
/DEF:${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def 
/OUT:${CMAKE_BINARY_DIR}/importlibs/lib${_name}.lib 
${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.obj ${_libraries}
-        DEPENDS ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.obj 
${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def)
-
-    # Add the importlib target
-    add_custom_target(
-        lib${_name}
-        DEPENDS ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.lib)
-
-    add_dependencies(lib${_name} asm ${_dependencies})
+    # be clear about the language
+    
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/lib${_name}_stubs.asm 
PROPERTIES LANGUAGE "ASM")
+
+    # add our library
+    # NOTE: as stub file and def file are generated in one pass, depending on 
one is like depending on the other
+    add_library(lib${_name} STATIC 
+        ${CMAKE_CURRENT_BINARY_DIR}/lib${_name}_stubs.asm)
+    
+    # Add necessary importlibs for redirections. Still necessary ?
+    if(ARGN)
+        target_link_libraries(lib${_name} ${ARGN})
+    endif()
+    
+    # set correct link rule
+    set_target_properties(lib${_name} PROPERTIES LINKER_LANGUAGE "IMPLIB"
+        STATIC_LIBRARY_FLAGS 
"/DEF:${CMAKE_CURRENT_BINARY_DIR}\\lib${_name}_exp.def")
 endfunction()
 
 macro(add_delay_importlibs MODULE)
     foreach(LIB ${ARGN})
         add_target_link_flags(${MODULE} "/DELAYLOAD:${LIB}.dll")
-        target_link_libraries(${MODULE} 
${CMAKE_BINARY_DIR}/importlibs/lib${LIB}.LIB)
-        add_dependencies(${MODULE} lib${LIB})
+        target_link_libraries(${MODULE} lib${LIB})
     endforeach()
     target_link_libraries(${MODULE} delayimp)
 endmacro()


Reply via email to