mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 02:32:18 +00:00
Merge pull request #928 from SRSaunders/rbdmap-fixes
rbdmap build warning fixes for gcc/posix and MSVC/win32
This commit is contained in:
commit
e54fc22180
2 changed files with 72 additions and 15 deletions
|
@ -268,6 +268,18 @@ if(MSVC)
|
|||
OBJECT_DEPENDS "precompiled.pch"
|
||||
)
|
||||
|
||||
# SRS - disable certain MSVC warnings for select third-party source libraries, consider updating versions in the future?
|
||||
set_source_files_properties(
|
||||
${MC_IMTUI_SOURCES} ${MC_IMGUI_SOURCES}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "/wd4005 /wd4244 /wd4305" # C4005: macro redefinition, C4244: type conversion with possible loss of data, C4305: trucation from double to float
|
||||
)
|
||||
set_source_files_properties(
|
||||
${PDCURSES_SOURCES} ${WINCON_SOURCES}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "/wd4244 /wd4267 /wd4996" # C4244, C4267: type conversion with possible loss of data, C4996: declared deprecated
|
||||
)
|
||||
|
||||
add_executable(rbdmap ${MC_SOURCES_ALL} ${MC_INCLUDES_ALL})
|
||||
add_dependencies(rbdmap idlib)
|
||||
target_link_libraries(rbdmap idlib winmm imtui-pdcurses ${ZLIB_LIBRARY})
|
||||
|
@ -289,6 +301,14 @@ else()
|
|||
endforeach()
|
||||
endif()
|
||||
|
||||
# SRS - disable certain gcc/clang warnings for select third-party source libraries, consider updating versions in the future?
|
||||
set_source_files_properties(
|
||||
${MC_ZLIB_SOURCES}
|
||||
${MC_MINIZIP_SOURCES}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-stringop-overread -Wno-deprecated-non-prototype"
|
||||
)
|
||||
|
||||
include_directories(.)
|
||||
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
|
@ -307,6 +327,12 @@ else()
|
|||
SEPARATE_ARGUMENTS(_compiler_FLAGS)
|
||||
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
# SRS - USE_OPTICK not useful for rbdmap, but definition required to avoid mismatch with idlib precompiled header
|
||||
if(OPTICK)
|
||||
LIST(APPEND _compiler_FLAGS -DUSE_OPTICK=1)
|
||||
else()
|
||||
LIST(APPEND _compiler_FLAGS -DUSE_OPTICK=0)
|
||||
endif()
|
||||
add_custom_target(precomp_header_rbdmap ALL
|
||||
COMMAND ${CMAKE_CXX_COMPILER} ${_compiler_FLAGS} -x c++-header precompiled.h -o precompiled.h.gch
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
|
@ -318,6 +344,34 @@ else()
|
|||
add_dependencies(rbdmap idlib)
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
add_dependencies(rbdmap precomp_header_rbdmap)
|
||||
|
||||
if(WIN32)
|
||||
set(remove_command "del")
|
||||
set(idlib_dir_slash "${CMAKE_SOURCE_DIR}\\idlib\\")
|
||||
else()
|
||||
set(remove_command "rm")
|
||||
set(idlib_dir_slash "${CMAKE_SOURCE_DIR}/idlib/")
|
||||
endif()
|
||||
|
||||
# SRS - delete precompiled header file after executable is compiled: command line build case
|
||||
if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja")
|
||||
add_custom_target(rm_precomp_header_rbdmap ALL
|
||||
COMMAND ${remove_command} "precompiled.h.gch"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "remove tools/compilers/precompiled.h.gch"
|
||||
)
|
||||
add_dependencies(rm_precomp_header_rbdmap rbdmap)
|
||||
|
||||
# SRS - delete precompiled header files after executable is compiled: IDE build case (e.g. Xcode)
|
||||
else()
|
||||
add_custom_command(TARGET rbdmap POST_BUILD
|
||||
# SRS - added wildcards to remove tmp files from cmake ZERO_CHECK regeneration
|
||||
COMMAND ${remove_command} "${idlib_dir_slash}precompiled.h*.gch*"
|
||||
COMMAND ${remove_command} "precompiled.h*.gch*"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "remove idlib/precompiled.h.gch and tools/compilers/precompiled.h.gch"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(rbdmap idlib ${CURSES_NCURSES_LIBRARY} ${ZLIB_LIBRARY})
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <fnmatch.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "imtui/imtui.h"
|
||||
#include "imtui/imtui-impl-ncurses.h"
|
||||
|
@ -315,23 +316,25 @@ int Sys_ListFiles( const char* directory, const char* extension, idStrList& list
|
|||
|
||||
// DG: use readdir_r instead of readdir for thread safety
|
||||
// the following lines are from the readdir_r manpage.. fscking ugly.
|
||||
int nameMax = pathconf( directory, _PC_NAME_MAX );
|
||||
if( nameMax == -1 )
|
||||
{
|
||||
nameMax = 255;
|
||||
}
|
||||
int direntLen = offsetof( struct dirent, d_name ) + nameMax + 1;
|
||||
//int nameMax = pathconf( directory, _PC_NAME_MAX );
|
||||
//if( nameMax == -1 )
|
||||
//{
|
||||
// nameMax = 255;
|
||||
//}
|
||||
//int direntLen = offsetof( struct dirent, d_name ) + nameMax + 1;
|
||||
|
||||
struct dirent* entry = ( struct dirent* )Mem_Alloc( direntLen, TAG_CRAP );
|
||||
//struct dirent* entry = ( struct dirent* )Mem_Alloc( direntLen, TAG_CRAP );
|
||||
|
||||
if( entry == NULL )
|
||||
{
|
||||
common->Warning( "Sys_ListFiles: Mem_Alloc for entry failed!" );
|
||||
closedir( fdir );
|
||||
return 0;
|
||||
}
|
||||
//if( entry == NULL )
|
||||
//{
|
||||
// common->Warning( "Sys_ListFiles: Mem_Alloc for entry failed!" );
|
||||
// closedir( fdir );
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
while( readdir_r( fdir, entry, &d ) == 0 && d != NULL )
|
||||
//while( readdir_r( fdir, entry, &d ) == 0 && d != NULL )
|
||||
// SRS - readdir_r() is deprecated on linux, readdir() is thread safe with different dir streams
|
||||
while( ( d = readdir( fdir ) ) != NULL )
|
||||
{
|
||||
// DG end
|
||||
idStr::snPrintf( search, sizeof( search ), "%s/%s", directory, d->d_name );
|
||||
|
@ -361,7 +364,7 @@ int Sys_ListFiles( const char* directory, const char* extension, idStrList& list
|
|||
}
|
||||
|
||||
closedir( fdir );
|
||||
Mem_Free( entry );
|
||||
//Mem_Free( entry );
|
||||
|
||||
if( debug )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue