common.cmake 5.23 KB
Newer Older
Jan Möbius's avatar
 
Jan Möbius committed
1
2
3
4
5
6
7
set (ACG_PROJECT_MACOS_BUNDLE "1")

macro (acg_modify_project_dirs)
  # set directory structures for the different platforms
  if (WIN32)
    add_definitions(
      -D_USE_MATH_DEFINES -DNOMINMAX
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
8
      -DOPENFLIPPER_APPDIR="."
Jan Möbius's avatar
 
Jan Möbius committed
9
10
11
12
13
14
15
16
      -DOPENFLIPPER_PLUGINDIR="${ACG_PROJECT_PLUGINDIR}"
      -DOPENFLIPPER_DATADIR="${ACG_PROJECT_DATADIR}"
    )
    if (NOT EXISTS ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_BINDIR})
      file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_BINDIR})
    endif ()
  elseif (APPLE)
    set (MAC_OPENFLIPPER_BASEDIR "OpenFlipper.app/Contents/Resources")
Jan Möbius's avatar
Jan Möbius committed
17
18
19
20
    set (ACG_PROJECT_DATADIR "${MAC_OPENFLIPPER_BASEDIR}")
    set (ACG_PROJECT_PLUGINDIR "${MAC_OPENFLIPPER_BASEDIR}/Plugins")
    set (ACG_PROJECT_LIBDIR "${MAC_OPENFLIPPER_BASEDIR}/../MacOS")
    set (ACG_PROJECT_BINDIR "${MAC_OPENFLIPPER_BASEDIR}/../MacOS")
Jan Möbius's avatar
 
Jan Möbius committed
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
    add_definitions(
      -DOPENFLIPPER_APPDIR="../Resources"
      -DOPENFLIPPER_PLUGINDIR="Plugins"
      -DOPENFLIPPER_DATADIR="."
    )
  else ()
    add_definitions(
      -DOPENFLIPPER_APPDIR=".."
      -DOPENFLIPPER_PLUGINDIR="${ACG_PROJECT_PLUGINDIR}"
      -DOPENFLIPPER_DATADIR="${ACG_PROJECT_DATADIR}"
    )
  endif ()
endmacro ()

# search all plugins and add them to build
function (of_add_plugins)
    file (
        GLOB _plugins_in
        RELATIVE "${CMAKE_SOURCE_DIR}"
        "${CMAKE_SOURCE_DIR}/Plugin-*/CMakeLists.txt"
    )

    foreach (_plugin ${_plugins_in})
        get_filename_component (_plugin_dir ${_plugin} PATH)
        add_subdirectory (${CMAKE_SOURCE_DIR}/${_plugin_dir})
    endforeach ()
endfunction ()

# print plugin statistics
function (of_print_plugin_stats)
51

Jan Möbius's avatar
 
Jan Möbius committed
52
53
54
55
56
57
58
  acg_color_message ("\n${_escape}[4mPlugin configure check results:${_escape}[0m\n")
  file (
    GLOB _plugins_in
    RELATIVE "${CMAKE_SOURCE_DIR}"
    "${CMAKE_SOURCE_DIR}/Plugin-*"
  )

Jan Möbius's avatar
Jan Möbius committed
59
60
  list (SORT _plugins_in)

Jan Möbius's avatar
 
Jan Möbius committed
61
62
63
64
65
66
67
68
69
70
  foreach (_plugin ${_plugins_in})
    string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
    string (TOUPPER ${_plugin_name} _PLUGIN)
    if (NOT EXISTS ${CMAKE_SOURCE_DIR}/${_plugin}/CMakeLists.txt AND DISABLE_QMAKE_BUILD)
      list (APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_SOURCE_DIR}/${_plugin}")
    elseif (DISABLE_PLUGIN_${_PLUGIN})
      list (APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_SOURCE_DIR}/${_plugin}")
    endif ()
  endforeach ()

71
72
73
74
75
76
77

  # Sort plugins into lists depending on configure status:
  set (PLUGINS_OK "")
  set (PLUGINS_DISABLED "")
  set (PLUGINS_DEPENDENCIES "")
  set (PLUGINS_NO_CMAKE "")

Jan Möbius's avatar
 
Jan Möbius committed
78
  foreach (_plugin ${_plugins_in})
79
80
81
     string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
     string (TOUPPER ${_plugin_name} _PLUGIN)
     acg_format_string (${_plugin_name} 25 _plugin_name)
Jan Möbius's avatar
 
Jan Möbius committed
82

83
84
     if (DISABLE_PLUGIN_${_PLUGIN})
          list( APPEND PLUGINS_DISABLED ${_plugin} )
Jan Möbius's avatar
 
Jan Möbius committed
85
      elseif (NOT EXISTS ${CMAKE_SOURCE_DIR}/${_plugin}/CMakeLists.txt)
86
           list( APPEND PLUGINS_NO_CMAKE ${_plugin} )
Jan Möbius's avatar
 
Jan Möbius committed
87
88
      else ()
          if (OPENFLIPPER_${_PLUGIN}_BUILD)
89
              list( APPEND PLUGINS_OK ${_plugin} )
Jan Möbius's avatar
 
Jan Möbius committed
90
          else ()
91
              list( APPEND PLUGINS_DEPENDENCIES ${_plugin} )
Jan Möbius's avatar
 
Jan Möbius committed
92
93
94
          endif ()
      endif ()
  endforeach ()
95
96
97
98

  message ("")

  # Print all plugins, which have no cmake build system
99
100
101
102
103
  acg_color_message ("\n${_escape}[4mPlugins without cmake build system:${_escape}[0m\n")
  foreach (_plugin ${PLUGINS_NO_CMAKE})
    string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
    string (TOUPPER ${_plugin_name} _PLUGIN)
    acg_format_string (${_plugin_name} 25 _plugin_name)
104
 
105
106
    acg_color_message ("  ${_plugin_name}: ${_escape}[1;34mNo CMake build system${_escape}[0m")
  endforeach ()
107

108
  message ("")
109
110

  # Print all plugins, which are ok
111
112
113
114
115
  acg_color_message ("\n${_escape}[4mPlugins configured successfully:${_escape}[0m\n")
  foreach (_plugin ${PLUGINS_OK})
    string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
    string (TOUPPER ${_plugin_name} _PLUGIN)
    acg_format_string (${_plugin_name} 25 _plugin_name)
116
 
117
118
    acg_color_message ("  ${_plugin_name}: ${_escape}[1;32mYes${_escape}[0m")
  endforeach ()
119

120
  message ("")
121
122
123


  # Print all plugins, which are disabled
124
125
126
127
128
129
130
131
  acg_color_message ("\n${_escape}[4mPlugins disabled:${_escape}[0m\n")
  foreach (_plugin ${PLUGINS_DISABLED})
    string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
    string (TOUPPER ${_plugin_name} _PLUGIN)
    acg_format_string (${_plugin_name} 25 _plugin_name)
                                                                                     
    acg_color_message ("  ${_plugin_name}: ${_escape}[1;34mDisabled${_escape}[0m")
  endforeach ()
132

133
  message ("")
134

135
136
137


  # Print all plugins, which have missing dependencies
138
139
140
141
142
143
144
145
146
147
  acg_color_message ("\n${_escape}[4mPlugins with missing dependencies:${_escape}[0m\n")
  foreach (_plugin ${PLUGINS_DEPENDENCIES})
    string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
    string (TOUPPER ${_plugin_name} _PLUGIN)
    acg_format_string (${_plugin_name} 25 _plugin_name)
                                                                                     
    acg_color_message ("  ${_plugin_name}: ${_escape}[1;31mNo${_escape}[0m (Missing dependencies :${_${_PLUGIN}_MISSING_DEPS})")
  endforeach ()
  
  message ("")
148
 
149

150
  if ( NOT WIN32 )
151
    message("${_escape}[4mCurrent Build Type:${_escape}[0m ${_escape}[1;34m ${CMAKE_BUILD_TYPE} ${_escape}[0m")
152
  endif()
Jan Möbius's avatar
 
Jan Möbius committed
153
  message ("")
154
155


Jan Möbius's avatar
 
Jan Möbius committed
156
endfunction ()