common.cmake 6.72 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
Matthias Möller's avatar
Matthias Möller committed
8
      -D_CRT_SECURE_NO_WARNINGS
Jan Möbius's avatar
Dennis:    
Jan Möbius committed
9
      -DOPENFLIPPER_APPDIR="."
Jan Möbius's avatar
 
Jan Möbius committed
10
11
12
13
14
15
16
17
      -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
18
19
20
21
    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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    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"
Jan Möbius's avatar
Jan Möbius committed
42
        "${CMAKE_SOURCE_DIR}/PluginCollection-*/Plugin-*/CMakeLists.txt"
Jan Möbius's avatar
 
Jan Möbius committed
43
    )
44
    
Jan Möbius's avatar
 
Jan Möbius committed
45
46
47
48
    foreach (_plugin ${_plugins_in})
        get_filename_component (_plugin_dir ${_plugin} PATH)
        add_subdirectory (${CMAKE_SOURCE_DIR}/${_plugin_dir})
    endforeach ()
49
    set(LOADED_PACKAGES ${LOADED_PACKAGES} PARENT_SCOPE)
Jan Möbius's avatar
 
Jan Möbius committed
50
51
endfunction ()

Jan Möbius's avatar
Jan Möbius committed
52
53
54
55
56
57
58
59
60
61
macro(_get_plugin_name _path _name)

   # Only get the plugins name:
   string (REGEX MATCH "Plugin-.+[/\\]?$" ${_name} ${${_path}})

   # Strip the Plugin- Prefix
   string (REPLACE "Plugin-" "" ${_name} ${${_name}})

endmacro()

Jan Möbius's avatar
 
Jan Möbius committed
62
63
# print plugin statistics
function (of_print_plugin_stats)
64

Jan Möbius's avatar
 
Jan Möbius committed
65
66
67
68
69
  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
70
    "${CMAKE_SOURCE_DIR}/PluginCollection-*/Plugin-*"
Jan Möbius's avatar
 
Jan Möbius committed
71
72
  )

Jan Möbius's avatar
Jan Möbius committed
73
74
  list (SORT _plugins_in)

Jan Möbius's avatar
 
Jan Möbius committed
75
  foreach (_plugin ${_plugins_in})
Jan Möbius's avatar
Jan Möbius committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

    # Extract plugin name from path
    _get_plugin_name( _plugin _plugin_name )

    # Possibly get the collection name
    string (REGEX MATCH "PluginCollection-.+[/\\]" collection_name ${_plugin})
   
    # If plugin belongs to a selection, we check that here
    if ( collection_name )
        # Strip the Plugin- Prefix
        string (REPLACE "PluginCollection-" "" collection_name ${collection_name})
        string (REPLACE "/" "" collection_name ${collection_name})
    endif()

    # TODO Group the plugins by selection!
    # TODO Correctly sort plugins by their name

    # We need the upper case name that is used for the plugin handling variables
Jan Möbius's avatar
 
Jan Möbius committed
94
    string (TOUPPER ${_plugin_name} _PLUGIN)
Jan Möbius's avatar
Jan Möbius committed
95

Jan Möbius's avatar
 
Jan Möbius committed
96
97
98
99
100
101
102
    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 ()

103
104
105
106
107
108
109

  # 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
110
  foreach (_plugin ${_plugins_in})
Jan Möbius's avatar
Jan Möbius committed
111
112
113
114
115

     # Extract plugin name from path
     _get_plugin_name( _plugin _plugin_name )

     # We need the upper case name that is used for the plugin handling variables
116
     string (TOUPPER ${_plugin_name} _PLUGIN)
Jan Möbius's avatar
Jan Möbius committed
117
118
119
120
121
122
123
124
125

     # Disable the problematic plugins in the cpack pass
     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 ()

     
126
     acg_format_string (${_plugin_name} 25 _plugin_name)
Jan Möbius's avatar
 
Jan Möbius committed
127

128
     if (DISABLE_PLUGIN_${_PLUGIN})
Jan Möbius's avatar
Jan Möbius committed
129
          list( APPEND PLUGINS_DISABLED ${_plugin_name} )
Jan Möbius's avatar
 
Jan Möbius committed
130
      elseif (NOT EXISTS ${CMAKE_SOURCE_DIR}/${_plugin}/CMakeLists.txt)
Jan Möbius's avatar
Jan Möbius committed
131
           list( APPEND PLUGINS_NO_CMAKE ${_plugin_name} )
Jan Möbius's avatar
 
Jan Möbius committed
132
133
      else ()
          if (OPENFLIPPER_${_PLUGIN}_BUILD)
Jan Möbius's avatar
Jan Möbius committed
134
              list( APPEND PLUGINS_OK ${_plugin_name} )
Jan Möbius's avatar
 
Jan Möbius committed
135
          else ()
Jan Möbius's avatar
Jan Möbius committed
136
              list( APPEND PLUGINS_DEPENDENCIES ${_plugin_name} )
Jan Möbius's avatar
 
Jan Möbius committed
137
138
139
          endif ()
      endif ()
  endforeach ()
140
141
142

  message ("")

Jan Möbius's avatar
Jan Möbius committed
143
144
145
  # The minimal distance to the : to allow all plugin names to fit into the column
  set (SPACING 30)

146
  # Print all plugins, which have no cmake build system
147
148
149
  acg_color_message ("\n${_escape}[4mPlugins without cmake build system:${_escape}[0m\n")
  foreach (_plugin ${PLUGINS_NO_CMAKE})
    string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
Jan Möbius's avatar
Jan Möbius committed
150
    acg_format_string (${_plugin_name} ${SPACING} _plugin_name)
151
 
152
153
    acg_color_message ("  ${_plugin_name}: ${_escape}[1;34mNo CMake build system${_escape}[0m")
  endforeach ()
154

155
  message ("")
156
157

  # Print all plugins, which are ok
158
159
160
  acg_color_message ("\n${_escape}[4mPlugins configured successfully:${_escape}[0m\n")
  foreach (_plugin ${PLUGINS_OK})
    string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
Jan Möbius's avatar
Jan Möbius committed
161
    acg_format_string (${_plugin_name} ${SPACING} _plugin_name)
162
 
163
164
    acg_color_message ("  ${_plugin_name}: ${_escape}[1;32mYes${_escape}[0m")
  endforeach ()
165

166
  message ("")
167
168
169


  # Print all plugins, which are disabled
170
171
172
  acg_color_message ("\n${_escape}[4mPlugins disabled:${_escape}[0m\n")
  foreach (_plugin ${PLUGINS_DISABLED})
    string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
Jan Möbius's avatar
Jan Möbius committed
173
    acg_format_string (${_plugin_name} ${SPACING} _plugin_name)
174
175
176
                                                                                     
    acg_color_message ("  ${_plugin_name}: ${_escape}[1;34mDisabled${_escape}[0m")
  endforeach ()
177

178
  message ("")
179

180
  # Print all plugins, which have missing dependencies
181
182
183
184
  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)
185
186
187
188
189
    acg_format_string (${_plugin_name} ${SPACING} _plugin_name_spaced)
    string(STRIP ${_PLUGIN} _PLUGIN)
    
    acg_color_message ("  ${_plugin_name_spaced}: ${_escape}[1;31mNo${_escape}[0m (Missing dependencies :${_${_PLUGIN}_MISSING_DEPS})")
   
190
191
192
  endforeach ()
  
  message ("")
193
 
194

195
  if ( NOT WIN32 )
196
    message("${_escape}[4mCurrent Build Type:${_escape}[0m ${_escape}[1;34m ${CMAKE_BUILD_TYPE} ${_escape}[0m")
197
  endif()
Jan Möbius's avatar
 
Jan Möbius committed
198
  message ("")
199
200


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