# examples/CMakeLists.txt
# Copyright (C) 2007 Andrew Ross
# Copyright (C) 2007 Alan W. Irwin

include_directories(${CMAKE_SOURCE_DIR}/include ${PANGOFT2_includedir})

add_executable(example0 MissingGlyphExample.cpp)
target_link_libraries(example0 LASi)

add_test(example0 ./example0 example0.ps)

add_executable(example1 SimpleLASiExample.cpp)
target_link_libraries(example1 LASi)

add_test(example1 ./example1 example1.ps)

add_executable(example2 ComplexTextLayoutExample.cpp)
target_link_libraries(example2 LASi)

add_test(example2 ./example2 example2.ps)

install(FILES
MissingGlyphExample.cpp
SimpleLASiExample.cpp
ComplexTextLayoutExample.cpp
README 
Example_1_Result.png
Example_2_Result.png
DESTINATION ${DATA_DIR}/examples
)

# Sort out RPATH issues for build of installed examples.
if(USE_RPATH)
  get_target_property(_LIB_INSTALL_RPATH LASi INSTALL_RPATH)
  string(REGEX REPLACE ";" ":" LIB_INSTALL_RPATH "${_LIB_INSTALL_RPATH}")
  set(RPATHCMD "-Wl,-rpath -Wl,${LIB_INSTALL_RPATH}")
endif(USE_RPATH)

# Sort out PKG_CONFIG_PATH issues for build of installed examples.

if("$ENV{PKG_CONFIG_PATH}" STREQUAL "")
  set(PKG_CONFIG_PATH "${libdir}/pkgconfig")
else("$ENV{PKG_CONFIG_PATH}" STREQUAL "")
  set(PKG_CONFIG_PATH "${libdir}/pkgconfig:$ENV{PKG_CONFIG_PATH}")
endif("$ENV{PKG_CONFIG_PATH}" STREQUAL "")
      
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Makefile.examples.in
${CMAKE_CURRENT_BINARY_DIR}/Makefile.examples
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile.examples
DESTINATION ${DATA_DIR}/examples
RENAME Makefile
)
