Skip to content

Commit

Permalink
Define _CRT_SECURE_NO_WARNINGS to remove unneeded warnings in MSVC (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 authored May 26, 2020
1 parent f145241 commit e3aa7f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ set_target_properties(dmlc PROPERTIES
CXX_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON)
list(APPEND LINKED_LIBRARIES_PRIVATE dmlc)
if (MSVC)
target_compile_options(dmlc PRIVATE
-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
if (TARGET dmlc_unit_tests)
target_compile_options(dmlc_unit_tests PRIVATE
-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
endif (TARGET dmlc_unit_tests)
endif (MSVC)

# rabit
set(RABIT_BUILD_DMLC OFF)
Expand All @@ -125,8 +133,16 @@ add_subdirectory(rabit)

if (RABIT_MOCK)
list(APPEND LINKED_LIBRARIES_PRIVATE rabit_mock_static)
if (MSVC)
target_compile_options(rabit_mock_static PRIVATE
-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
endif (MSVC)
else()
list(APPEND LINKED_LIBRARIES_PRIVATE rabit)
if (MSVC)
target_compile_options(rabit PRIVATE
-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
endif (MSVC)
endif(RABIT_MOCK)
foreach(lib rabit rabit_base rabit_empty rabit_mock rabit_mock_static)
# Explicitly link dmlc to rabit, so that configured header (build_config.h)
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ endif (WIN32 AND MINGW)
if (MSVC)
target_compile_options(objxgboost PRIVATE
$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>
-D_CRT_SECURE_NO_WARNINGS
-D_CRT_SECURE_NO_DEPRECATE
)
endif (MSVC)

Expand Down
2 changes: 2 additions & 0 deletions tests/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ endif (USE_CUDA)
if (MSVC)
target_compile_options(testxgboost PRIVATE
$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>
-D_CRT_SECURE_NO_WARNINGS
-D_CRT_SECURE_NO_DEPRECATE
)
endif (MSVC)

Expand Down

0 comments on commit e3aa7f1

Please sign in to comment.