enable_png.cmake 866 Bytes
Newer Older
1
2
3
4
5
6
macro(enable_png _FLAGS_ _INC_DIRS_ _LIBS_)
    if (${ARGC} GREATER 3)
      set(LINK_EXECUTABLE ON)
    else ()
      set(LINK_EXECUTABLE OFF)
    endif ()
7

8
    find_file(_PNG_H png.h
9
10
11
      HINTS ENV CPATH /usr/include
      DOC "headerfile png.h for PNG-READER")

12
    if (_PNG_H)
13
14
      get_filename_component(PNG_PATH ${_PNG_H} PATH)
      list(APPEND ${_INC_DIRS_} ${PNG_PATH})
15
    else()
16
      message(FATAL_ERROR "Could not find the PNG header png.h.")
17
    endif()
18

19
    if (LINK_EXECUTABLE)
20
21
22
23
24
25
26
27
28
29
30
31
      find_library(_PNG_LIB png
        HINTS ENV LIBRARY_PATH
        DOC "The PNG library")
      if (_PNG_LIB)
        list(APPEND ${_LIBS_} ${_PNG_LIB})
      else()
        message(FATAL_ERROR "Could not find the PNG library")
      endif()
    endif (LINK_EXECUTABLE)

    list(APPEND ${_FLAGS_} "-DHAVE_PNG=1")
endmacro(enable_png)