summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: fad5d2207d119bc963f5abb98810def46231fd67 (plain)
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
30
31
32
33
cmake_minimum_required(VERSION 3.11)

project(fbglExamples C)

add_custom_target(run-examples)

set(FBGL_HEADER "fbgl.h")
set(EXAMPLES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/examples")

# find freetype2
find_package(PkgConfig REQUIRED)
pkg_check_modules(FREETYPE2 REQUIRED freetype2)
include_directories(${FREETYPE2_INCLUDE_DIRS})

function(add_example NAME)
  add_executable("${NAME}" "${EXAMPLES_DIR}/${NAME}.c" "${FBGL_HEADER}")
  target_compile_features("${NAME}" PRIVATE c_std_99)
  target_compile_options("${NAME}" PRIVATE -Wall -Wextra -Wpedantic)
  target_include_directories("${NAME}" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
  target_link_libraries("${NAME}" PRIVATE ${FREETYPE2_LIBRARIES} m)
  add_custom_target("run_${NAME}" COMMAND "${NAME}" VERBATIM)
  add_dependencies("run_${NAME}" "${NAME}")
  add_dependencies(run-examples "run_${NAME}")
endfunction()

add_example(line)
add_example(rectangle)
add_example(red)
add_example(texture)
add_example(framebuf_info)
add_example(text)
add_example(texture_show_fps)
add_example(circle)