Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CMake file and use vsnprintf to avoid compiling errors #673

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if ExaGO should have this...


#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
Loading