Skip to content

Commit

Permalink
add cflag Wall and Werror in debug mode; change vsprintf to vsnprintf (
Browse files Browse the repository at this point in the history
  • Loading branch information
nychiang authored Nov 30, 2023
1 parent 27f24ce commit 2378fde
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_FLAGS "-Wall -Werror")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Werror")

if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
Expand Down Expand Up @@ -105,7 +105,9 @@ if(NOT "${HIOP_EXTRA_LINK_FLAGS}" STREQUAL "")
endif()

if(HIOP_USE_MPI)
find_package(MPI REQUIRED)
find_package(MPI REQUIRED COMPONENTS C CXX Fortran)

#find_package(MPI REQUIRED)
if(NOT DEFINED MPI_CXX_COMPILER)
set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
set(CMAKE_C_COMPILER ${MPI_C_COMPILER})
Expand All @@ -114,7 +116,7 @@ if(HIOP_USE_MPI)

set(CMAKE_Fortran_COMPILER ${MPI_Fortran_COMPILER})
include_directories(${MPI_Fortran_ADDITIONAL_INCLUDE_DIRS} ${MPI_Fortran_COMPILER_INCLUDE_DIRS} )
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D HIOP_USE_MPI")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D HIOP_USE_MPI")

target_link_libraries(hiop_tpl INTERFACE MPI::MPI_CXX MPI::MPI_CXX)
set(HIOP_EXTRA_MPI_FLAGS "" CACHE STRING "Extra arguments to mpiexec when running tests")
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/hiopLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void hiopLogger::printf(hiopOutVerbosity v, const char* format, ...)

va_list args;
va_start(args, format);
vsprintf(buff_,format, args);
vsnprintf(buff_,4096,format, args);
fprintf(f_,"%s",buff_);
va_end(args);

Expand All @@ -155,7 +155,7 @@ void hiopLogger::printf_error(hiopOutVerbosity v, const char* format, ...)
char buff[4096];
va_list args;
va_start (args, format);
vsprintf (buff,format, args);
vsnprintf(buff,4096,format, args);
fprintf(stderr,"%s",buff);
va_end (args);
};
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/hiopOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ void hiopOptions::log_printf(hiopOutVerbosity v, const char* format, ...)
char buff[1024];
va_list args;
va_start (args, format);
vsprintf (buff,format, args);
vsnprintf(buff,1024,format, args);
if(log_) {
log_->printf(v,buff);
} else {
Expand Down

0 comments on commit 2378fde

Please sign in to comment.