diff --git a/CMakeLists.txt b/CMakeLists.txt index 3583b78b894..00c4e7e2741 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,6 +292,13 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to # This will set I18N_DEFS for later use set_i18n_language(${I18N_LANG}) + # For MSVC builds, this puts all debug symbols file in the same directory. + if(MSVC) + set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb") + else() #if(SEPARATE_DBG) + set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/symbols") + endif() + # Compiler specific definitions and macros if(MSVC) include(sdk/cmake/msvc.cmake) @@ -337,7 +344,7 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to add_subdirectory(sdk/include/asm) if(ARCH MATCHES "64$") - include(sdk/cmake/baseaddress64.cmake) + include(sdk/cmake/baseaddress64.cmake) elseif(NO_ROSSYM) include(sdk/cmake/baseaddress_dwarf.cmake) elseif(MSVC) @@ -346,13 +353,6 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to include(sdk/cmake/baseaddress.cmake) endif() - # For MSVC builds, this puts all debug symbols file in the same directory. - if(MSVC) - set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb") - elseif(SEPARATE_DBG) - set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/symbols") - endif() - #begin with boot so reactos_cab target is defined before all other modules add_subdirectory(boot) add_subdirectory(base) diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index 0ba7d21e391..5228acfa388 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -212,7 +212,33 @@ else() set(ARCH2 ${ARCH}) endif() -if(SEPARATE_DBG) +# Try to detect the linker and version +execute_process(COMMAND ${CMAKE_C_COMPILER} "-Wl,--version" ERROR_QUIET OUTPUT_VARIABLE LINKER_VERSION_OUTPUT) +if(LINKER_VERSION_OUTPUT MATCHES "GNU ld.*") + # Extract the version number + string(REGEX REPLACE ".*GNU ld \\(GNU Binutils\\) ([0-9\\.]+).*" "\\1" LD_VERSION_NUMBER ${LINKER_VERSION_OUTPUT}) + message (STATUS "Using GNU ld version ${LD_VERSION_NUMBER}") + + if(LD_VERSION_NUMBER VERSION_GREATER_EQUAL "2.42") + set(PDB_SUPPORTED TRUE) + else() + set(PDB_SUPPORTED FALSE) + endif() + message (STATUS "PDBs supported: ${PDB_SUPPORTED}") +else() + set(PDB_SUPPORTED FALSE) +endif() + +if(_WINKD_ AND PDB_SUPPORTED) + # Generate PDBs + message(STATUS "Generating PDB debug information.") + set(PDB_OPTION "-Wl,--pdb=${CMAKE_PDB_OUTPUT_DIRECTORY}/.pdb") + set(CMAKE_C_LINK_EXECUTABLE " -o ${PDB_OPTION}") + set(CMAKE_CXX_LINK_EXECUTABLE " -o ${PDB_OPTION}") + set(CMAKE_C_CREATE_SHARED_LIBRARY " -o ${PDB_OPTION}") + set(CMAKE_CXX_CREATE_SHARED_LIBRARY " -o ${PDB_OPTION}") + set(CMAKE_RC_CREATE_SHARED_LIBRARY " -o ${PDB_OPTION}") +elseif(SEPARATE_DBG) # PDB style debug puts all dwarf debug info in a separate dbg file message(STATUS "Building separate debug symbols") file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/symbols)