File: MaintainerFlags.cmake

package info (click to toggle)
mongo-c-driver 1.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 31,116 kB
  • sloc: ansic: 124,705; python: 2,971; sh: 138; makefile: 23
file content (29 lines) | stat: -rw-r--r-- 1,129 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
if (ENABLE_MAINTAINER_FLAGS AND NOT MSVC AND NOT MONGOC_MAINTAINER_FLAGS_SET)
   include (CheckCCompilerFlag)

   message (STATUS "Detecting available maintainer flags")
   file (READ "build/maintainer-flags.txt" MAINTAINER_FLAGS)

   # Convert file contents into a CMake list (where each element in the list
   # is one line of the file)
   #
   string (REGEX REPLACE ";" "\\\\;" MAINTAINER_FLAGS "${MAINTAINER_FLAGS}")
   string (REGEX REPLACE "\n" ";" MAINTAINER_FLAGS "${MAINTAINER_FLAGS}")

   foreach (MAINTAINER_FLAG ${MAINTAINER_FLAGS})
      # Avoid useless "Performing Test FLAG_OK" message.
      set (MESSAGES_ENABLED 0)
      check_c_compiler_flag ("${MAINTAINER_FLAG}" FLAG_OK)
      set (MESSAGES_ENABLED 1)
      if (FLAG_OK)
         message (STATUS "C compiler accepts ${MAINTAINER_FLAG}")
         set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MAINTAINER_FLAG}")
      else ()
         message (STATUS "C compiler does not accept ${MAINTAINER_FLAG}")
      endif ()
      unset (FLAG_OK CACHE)
   endforeach ()

   message (STATUS "Maintainer flags: ${CMAKE_C_FLAGS}")
   set (MONGOC_MAINTAINER_FLAGS_SET 1)
endif ()