aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/qpdfCheckFlag.cmake
blob: 8bd72b8813b25e2001a09f5eb36caa15417f084e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag)

function(qpdf_maybe_add_flag lang flag var)
  if(${lang} STREQUAL "C")
    check_c_compiler_flag(${flag} ${var})
  elseif(${lang} STREQUAL "CXX")
    check_cxx_compiler_flag(${flag} ${var})
  endif()
  if(${var})
    message(STATUS "Using ${flag}: YES")
    if(${lang} STREQUAL "C")
      # Add for C and C++
      add_compile_options(${flag})
    else()
      add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${flag}>)
    endif()
  else()
    message(STATUS "Using ${flag}: NO")
  endif()
endfunction()