cmake 添加编译选项的几种方式

CFLAGS

CMAKE__FLAGS

This is initialized for each language from environment variables:

  • CMAKE_C_FLAGS: Initialized by the CFLAGS environment variable.
  • CMAKE_CXX_FLAGS: Initialized by the CXXFLAGS environment variable.
  • CMAKE_CUDA_FLAGS: Initialized by the CUDAFLAGS environment variable.
  • CMAKE_Fortran_FLAGS: Initialized by the FFLAGS environment variable.

CMAKE_FLAGS

Flags for language when building for the configuration.

设置编译选项

SET(CMAKE_C_FLAGS_DEBUG "-g -D_DEBUG -O0")
SET(CMAKE_C_FLAGS_RELEASE "-g -DNDEBUG -O3")

SET(CMAKE_CXX_FLAGS_DEBUG "-g -D_DEBUG -O0")
SET(CMAKE_CXX_FLAGS_RELEASE "-g -DNDEBUG -O3")

你可能感兴趣的:(cmake 添加编译选项的几种方式)