Home > other >  C - using cmake add _CRT_SECURE_NO_WARNINGS definition
C - using cmake add _CRT_SECURE_NO_WARNINGS definition

Time:09-26

Whether can use cmake add _CRT_SECURE_NO_WARNINGS preprocessor definition?

Add_definitions (- CRT_SECURE_NO_WARNINGS)
Add_definitions (- _CRT_SECURE_NO_WARNINGS)
Add_definitions (_CRT_SECURE_NO_WARNINGS)

These are I have tried so far. These attempts are not successful.

CodePudding user response:

Use this:

If (MSVC)
Add_definitions (- D_CRT_SECURE_NO_WARNINGS)
Endif ()

About the official document, please refer to here. The general form is:

Add_definitions (DFOO - DBAR... )

Please note that if it applies to a single target, you should use target_compile_definitions.

CodePudding user response:

https://stackoverflow.com/questions/40779571/adding-crt-secure-no-warnings-definition-using-cmake

Ning is the translation machine
  • Related