summaryrefslogtreecommitdiffstats
path: root/cmake/fastd_module.cmake
blob: 1c2da9d5fe2ab24b145fdae5795dec461fd530dd (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
34
35
36
37
38
39
40
41
function(fastd_module type name)
  string(TOUPPER "${type}" TYPE)

  string(REPLACE - _ name_ "${name}")
  string(TOUPPER "${name_}" NAME)

  set(WITH_${TYPE}_${NAME} TRUE CACHE BOOL "Include the ${name} ${type}")

  if(WITH_${TYPE}_${NAME})
    add_library(${type}_${name_} STATIC ${ARGN})
    set_property(TARGET ${type}_${name_} PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")

    set_property(TARGET ${type}s APPEND PROPERTY LINK_LIBRARIES ${type}_${name_})

    list(APPEND ${TYPE}S ${name_})

    set_property(GLOBAL APPEND PROPERTY FASTD_${TYPE}S ${name_})
  endif(WITH_${TYPE}_${NAME})
endfunction(fastd_module)

function(fastd_module_include_directories type name)
  string(TOUPPER "${type}" TYPE)

  string(REPLACE - _ name_ "${name}")
  string(TOUPPER "${name_}" NAME)

  if(WITH_${TYPE}_${NAME})
    target_include_directories(${type}_${name_} PRIVATE ${ARGN})
  endif(WITH_${TYPE}_${NAME})
endfunction(fastd_module_include_directories)

function(fastd_module_link_libraries type name)
  string(TOUPPER "${type}" TYPE)

  string(REPLACE - _ name_ "${name}")
  string(TOUPPER "${name_}" NAME)

  if(WITH_${TYPE}_${NAME})
    target_link_libraries(${type}_${name_} ${ARGN})
  endif(WITH_${TYPE}_${NAME})
endfunction(fastd_module_link_libraries)