[CMake] using macros

Owen Hogarth II gurenchan at gmail.com
Thu Jan 14 02:25:02 EST 2016


I am trying to use a macro to enable c99 in some of my cmake modules.

In the top level cmake file I add this macro

macro(use_c99)
  if (CMAKE_VERSION VERSION_LESS "3.1")
    if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
      set (CMAKE_C_FLAGS "--std=gnu99 ${CMAKE_C_FLAGS}")
    endif ()
  else ()
    set (CMAKE_C_STANDARD 99)
  endif ()
endmacro(use_c99)

then in another CMakeLists.txt file I add
use_c99()

but I get this error:

CMake Error at source/internal_src/cube/CMakeLists.txt:1 (use_c
99):
  Unknown CMake command "use_c99".

why am I unable to use the macro? My main cmake is using 3.0.2 from debian
repository.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160114/8076e319/attachment.html>


More information about the CMake mailing list