Index: cmake/gcc.cmake =================================================================== --- cmake/gcc.cmake (revision 69057) +++ cmake/gcc.cmake (working copy) @@ -225,7 +225,13 @@ set(CMAKE_RC_CREATE_SHARED_LIBRARY " ${CMAKE_C_FLAGS} -o ") else() # Normal rsym build - get_target_property(RSYM native-rsym IMPORTED_LOCATION_NOCONFIG) + if(NEW_STYLE_BUILD) + string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type) + get_target_property(RSYM native-rsym IMPORTED_LOCATION_${_build_type}) + else() + get_target_property(RSYM native-rsym IMPORTED_LOCATION_NOCONFIG) + endif() + set(CMAKE_C_LINK_EXECUTABLE " ${CMAKE_C_FLAGS} -o " "${RSYM} -s ${REACTOS_SOURCE_DIR} ") Index: cmake/host-tools.cmake =================================================================== --- cmake/host-tools.cmake (revision 0) +++ cmake/host-tools.cmake (working copy) @@ -0,0 +1,37 @@ + +if(CMAKE_HOST_WIN32) + set(native_suffix ".exe") +endif() + +string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type) + +# List of host tools +list(APPEND host_tools_list bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc mkshelllink utf16le) +if(NOT MSVC) + list(APPEND host_tools_list rsym) +endif() + +foreach(_host_tool ${host_tools_list}) + if(MSVC_IDE) + get_filename_component(_tool_location "${CMAKE_CURRENT_BINARY_DIR}/host-tools/${CMAKE_BUILD_TYPE}/${_host_tool}${native_suffix}" ABSOLUTE) + else() + get_filename_component(_tool_location "${CMAKE_CURRENT_BINARY_DIR}/host-tools/${_host_tool}${native_suffix}" ABSOLUTE) + endif() + list(APPEND tools_binaries ${_tool_location}) + add_executable(native-${_host_tool} IMPORTED) + set_property(TARGET native-${_host_tool} PROPERTY IMPORTED_LOCATION_${_build_type} ${_tool_location}) + add_dependencies(native-${_host_tool} host-tools) +endforeach() + +include(ExternalProject) + +ExternalProject_Add(host-tools + SOURCE_DIR ${REACTOS_SOURCE_DIR} + BINARY_DIR ${REACTOS_BINARY_DIR}/host-tools + STAMP_DIR ${REACTOS_BINARY_DIR}/host-tools/stamps + BUILD_ALWAYS 1 + PREFIX host-tools + EXCLUDE_FROM_ALL 1 + CMAKE_ARGS "-DNEW_STYLE_BUILD=1" + INSTALL_COMMAND "" + BUILD_BYPRODUCTS ${tools_binaries}) Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 69057) +++ CMakeLists.txt (working copy) @@ -41,6 +41,10 @@ set(CMAKE_DISABLE_NINJA_DEPSLOG TRUE) endif() +if(NOT DEFINED NEW_STYLE_BUILD) + set(NEW_STYLE_BUILD FALSE) +endif() + if(NOT ARCH) set(ARCH i386) endif() @@ -80,6 +84,10 @@ if(NOT CMAKE_CROSSCOMPILING) + if(NEW_STYLE_BUILD) + set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR}) + endif() + add_definitions(-DTARGET_${ARCH}) if(MSVC) @@ -102,14 +110,20 @@ add_subdirectory(tools) add_subdirectory(lib) - if(NOT MSVC) - export(TARGETS bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc rsym mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- ) - else() - export(TARGETS bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- ) + if(NOT NEW_STYLE_BUILD) + if(NOT MSVC) + export(TARGETS bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc rsym mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- ) + else() + export(TARGETS bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- ) + endif() endif() else() + if(NEW_STYLE_BUILD) + include(cmake/host-tools.cmake) + endif() + # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search # programs in the host environment @@ -130,13 +144,14 @@ ${REACTOS_BINARY_DIR}/boot/ros_cab.txt ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt) - if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR) - set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build) + if(NOT NEW_STYLE_BUILD) + if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR) + set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build) + endif() + set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables") + include(${IMPORT_EXECUTABLES}) endif() - set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables") - include(${IMPORT_EXECUTABLES}) - if(DBG) add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE) else() Index: tools/cabman/CMakeLists.txt =================================================================== --- tools/cabman/CMakeLists.txt (revision 69057) +++ tools/cabman/CMakeLists.txt (working copy) @@ -7,5 +7,5 @@ raw.cxx) include_directories(${REACTOS_SOURCE_DIR}/include/reactos/libs/zlib) -add_executable(cabman ${SOURCE}) +add_host_tool(cabman ${SOURCE}) target_link_libraries(cabman zlibhost) Index: tools/cdmake/CMakeLists.txt =================================================================== --- tools/cdmake/CMakeLists.txt (revision 69057) +++ tools/cdmake/CMakeLists.txt (working copy) @@ -1,2 +1,2 @@ -add_executable(cdmake cdmake.c dirhash.c llmsort.c) +add_host_tool(cdmake cdmake.c dirhash.c llmsort.c) Index: tools/CMakeLists.txt =================================================================== --- tools/CMakeLists.txt (revision 69057) +++ tools/CMakeLists.txt (working copy) @@ -1,4 +1,11 @@ +function(add_host_tool _tool) + add_executable(${_tool} ${ARGN}) + if(NEW_STYLE_BUILD) + set_target_properties(${_tool} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TOOLS_FOLDER}) + endif() +endfunction() + #add_executable(pefixup pefixup.c) if(MSVC) @@ -5,17 +12,17 @@ add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() -add_executable(bin2c bin2c.c) -add_executable(gendib gendib/gendib.c) -add_executable(geninc geninc/geninc.c) -add_executable(mkshelllink mkshelllink/mkshelllink.c) -add_executable(obj2bin obj2bin/obj2bin.c) -add_executable(spec2def spec2def/spec2def.c) +add_host_tool(bin2c bin2c.c) +add_host_tool(gendib gendib/gendib.c) +add_host_tool(geninc geninc/geninc.c) +add_host_tool(mkshelllink mkshelllink/mkshelllink.c) +add_host_tool(obj2bin obj2bin/obj2bin.c) +add_host_tool(spec2def spec2def/spec2def.c) if(MSVC) set_property(SOURCE utf16le/utf16le.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " /EHsc") endif() -add_executable(utf16le utf16le/utf16le.cpp) +add_host_tool(utf16le utf16le/utf16le.cpp) add_subdirectory(cabman) add_subdirectory(cdmake) Index: tools/hpp/CMakeLists.txt =================================================================== --- tools/hpp/CMakeLists.txt (revision 69057) +++ tools/hpp/CMakeLists.txt (working copy) @@ -1,2 +1,2 @@ -add_executable(hpp hpp.c) +add_host_tool(hpp hpp.c) Index: tools/kbdtool/CMakeLists.txt =================================================================== --- tools/kbdtool/CMakeLists.txt (revision 69057) +++ tools/kbdtool/CMakeLists.txt (working copy) @@ -1,2 +1,2 @@ -add_executable(kbdtool data.c main.c output.c parser.c) +add_host_tool(kbdtool data.c main.c output.c parser.c) Index: tools/log2lines/CMakeLists.txt =================================================================== --- tools/log2lines/CMakeLists.txt (revision 69057) +++ tools/log2lines/CMakeLists.txt (working copy) @@ -13,5 +13,5 @@ util.c) include_directories(${REACTOS_SOURCE_DIR}/tools/rsym) -add_executable(log2lines ${SOURCE}) +add_host_tool(log2lines ${SOURCE}) target_link_libraries(log2lines rsym_common) Index: tools/mkhive/CMakeLists.txt =================================================================== --- tools/mkhive/CMakeLists.txt (revision 69057) +++ tools/mkhive/CMakeLists.txt (working copy) @@ -16,5 +16,5 @@ registry.c rtl.c) -add_executable(mkhive ${SOURCE}) +add_host_tool(mkhive ${SOURCE}) target_link_libraries(mkhive unicode cmlibhost inflibhost) Index: tools/rsym/CMakeLists.txt =================================================================== --- tools/rsym/CMakeLists.txt (revision 69057) +++ tools/rsym/CMakeLists.txt (working copy) @@ -4,12 +4,12 @@ if(ARCH STREQUAL "i386") add_definitions(-D_X86_) - add_executable(rsym rsym.c) + add_host_tool(rsym rsym.c) elseif(ARCH STREQUAL "amd64") - add_executable(rsym rsym64.c) + add_host_tool(rsym rsym64.c) elseif(ARCH STREQUAL "arm") add_executable(rsym rsym64.c) endif() target_link_libraries(rsym rsym_common dbghelphost zlibhost unicode) -add_executable(raddr2line rsym_common.c raddr2line.c) +add_host_tool(raddr2line rsym_common.c raddr2line.c) Index: tools/widl/CMakeLists.txt =================================================================== --- tools/widl/CMakeLists.txt (revision 69057) +++ tools/widl/CMakeLists.txt (working copy) @@ -32,5 +32,5 @@ # Taken from widl.rbuild add_definitions(-DINT16=SHORT) -add_executable(widl ${SOURCE}) +add_host_tool(widl ${SOURCE}) target_link_libraries(widl wpphost)