summaryrefslogtreecommitdiffstats
path: root/src/modules/CMakeLists.txt
blob: 774b4ebc60fd0c28651819f8be6f62e7f7014b7f (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
include_directories(${INCLUDES})

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MAD_BINARY_DIR}/src/modules)

set(STATIC_MODULES "")

macro(mad_module name)
  string(TOUPPER ${name} upper_name)
  
  set(WITH_${upper_name} ON CACHE BOOL "Enable module '${name}'")
  
  mark_as_advanced(WITH_STATIC_${upper_name})
  set(WITH_STATIC_${upper_name} OFF CACHE BOOL "Link module '${name}' statically")
  
  if(WITH_${upper_name})
    if(WITH_STATIC_${upper_name})
      add_library(${name} STATIC ${ARGN})
      set(STATIC_MODULES ${STATIC_MODULES} ${name} PARENT_SCOPE)
    else(WITH_STATIC_${upper_name})
      add_library(${name} MODULE ${ARGN})
      set_property(TARGET ${name} PROPERTY PREFIX "")
    endif(WITH_STATIC_${upper_name})
  endif(WITH_${upper_name})
endmacro(mad_module)

macro(mad_module_libraries name)
  string(TOUPPER ${name} upper_name)
  
  if(WITH_${upper_name})
    target_link_libraries(${name} ${ARGN})
  endif(WITH_${upper_name})
endmacro(mad_module_libraries)

add_subdirectory(FileLogger)
add_subdirectory(SystemBackendPosix)
add_subdirectory(SystemBackendProc)
add_subdirectory(UserBackendHome)

if(MYSQL_FOUND)
add_subdirectory(UserBackendMysql)
endif(MYSQL_FOUND)

SET(STATIC_MODULE_LOADERS "")
SET(STATIC_MODULE_LIST "")

foreach(module ${STATIC_MODULES})
  SET(STATIC_MODULE_LOADERS "${STATIC_MODULE_LOADERS}Mad::Common::Module* ${module}_create(Mad::Common::Application *application);\n")
  SET(STATIC_MODULE_LIST "${STATIC_MODULE_LIST}std::make_pair(\"${module}\", &${module}_create),\n")
endforeach(module ${STATIC_MODULES})

configure_file(${MAD_SOURCE_DIR}/src/modules/modules.cpp.in ${MAD_BINARY_DIR}/src/modules/modules.cpp)

add_library(modules STATIC
  modules.cpp modules.h
)
target_link_libraries(modules ${STATIC_MODULES})