aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/qpdfCheckFlag.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/qpdfCheckFlag.cmake')
-rw-r--r--cmake/qpdfCheckFlag.cmake21
1 files changed, 21 insertions, 0 deletions
diff --git a/cmake/qpdfCheckFlag.cmake b/cmake/qpdfCheckFlag.cmake
new file mode 100644
index 00000000..8bd72b88
--- /dev/null
+++ b/cmake/qpdfCheckFlag.cmake
@@ -0,0 +1,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()