summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-19 20:49:44 -0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-01-23 18:23:40 +0100
commit76212a91625cd72142d0fe27cb85ccc5b29fedf5 (patch)
tree236947a7a96be25219bc647ed311836578e9531e
parentdee24c3821ffbc14721dbfb041ac6cc010b9269b (diff)
CMake: infra to build modules (static, on or off).
-rw-r--r--cmake/config/common.cmake7
-rw-r--r--cmake/config/eina.cmake13
-rw-r--r--cmake/helpers/EflMacros.cmake192
-rw-r--r--src/lib/efl/config.h.cmake4
-rw-r--r--src/modules/eina/CMakeLists.txt20
-rw-r--r--src/modules/eina/mp/chained_pool/CMakeLists.txt2
-rw-r--r--src/modules/eina/mp/one_big/CMakeLists.txt2
-rw-r--r--src/modules/eina/mp/pass_through/CMakeLists.txt2
8 files changed, 208 insertions, 34 deletions
diff --git a/cmake/config/common.cmake b/cmake/config/common.cmake
index f41166201d..adb0bce112 100644
--- a/cmake/config/common.cmake
+++ b/cmake/config/common.cmake
@@ -16,12 +16,7 @@ set(VREV ${PROJECT_VERSION_TWEAK})
16set(EFL_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) 16set(EFL_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
17set(EFL_VERSION_MINOR ${PROJECT_VERSION_MINOR}) 17set(EFL_VERSION_MINOR ${PROJECT_VERSION_MINOR})
18 18
19set(BUILD_ALL_PROFILES release dev debug) 19EFL_OPTION(BUILD_PROFILE "How to build EFL" release CHOICE release;dev;debug)
20EFL_OPTION(BUILD_PROFILE "How to build EFL (one of: ${BUILD_ALL_PROFILES})" "release" STRING)
21list(FIND BUILD_ALL_PROFILES ${BUILD_PROFILE} RET)
22if (${RET} EQUAL -1)
23 message(FATAL_ERROR "Unknown BUILD_PROFILE=${BUILD_PROFILE}")
24endif()
25 20
26EFL_OPTION(EFL_NOLEGACY_API_SUPPORT "Whenever to disable non-Eo (Legacy) APIs" ON) 21EFL_OPTION(EFL_NOLEGACY_API_SUPPORT "Whenever to disable non-Eo (Legacy) APIs" ON)
27EFL_OPTION(EFL_EO_API_SUPPORT "Whenever to enable new Eo APIs" ON) 22EFL_OPTION(EFL_EO_API_SUPPORT "Whenever to enable new Eo APIs" ON)
diff --git a/cmake/config/eina.cmake b/cmake/config/eina.cmake
index 361488030f..20f9a12336 100644
--- a/cmake/config/eina.cmake
+++ b/cmake/config/eina.cmake
@@ -19,6 +19,19 @@ EFL_OPTION(EINA_MAGIC_DEBUG "magic debug of eina structure" ON)
19EFL_OPTION(EINA_DEBUG_THREADS "debugging of eina threads" ${EINA_DEBUG_THREADS}) 19EFL_OPTION(EINA_DEBUG_THREADS "debugging of eina threads" ${EINA_DEBUG_THREADS})
20EFL_OPTION(VALGRIND "valgrind support" ${VALGRIND}) 20EFL_OPTION(VALGRIND "valgrind support" ${VALGRIND})
21 21
22EFL_OPTION(EINA_BUILD_CHAINED "Build Eina's chained mempool" "ON" CHOICE ON;OFF;STATIC)
23EFL_OPTION(EINA_BUILD_ONE_BIG "Build Eina's one-big mempool" "ON" CHOICE ON;OFF;STATIC)
24EFL_OPTION(EINA_BUILD_PASS_THROUGH "Build Eina's pass-through mempool" "STATIC" CHOICE ON;OFF;STATIC)
25
26if(EINA_BUILD_CHAINED STREQUAL "STATIC")
27 set(EINA_STATIC_BUILD_CHAINED_POOL 1)
28endif()
29if(EINA_BUILD_ONE_BIG STREQUAL "STATIC")
30 set(EINA_STATIC_BUILD_ONE_BIG 1)
31endif()
32if(EINA_BUILD_PASS_THROUGH STREQUAL "STATIC")
33 set(EINA_STATIC_BUILD_PASS_THROUGH 1)
34endif()
22 35
23#check for symbols in pthread 36#check for symbols in pthread
24#TODO Make the definitions depending on the platform 37#TODO Make the definitions depending on the platform
diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake
index cb5d3e5a90..9ae80aaa3c 100644
--- a/cmake/helpers/EflMacros.cmake
+++ b/cmake/helpers/EflMacros.cmake
@@ -6,16 +6,38 @@
6# To extend the EFL_OPTIONS_SUMMARY() message, use 6# To extend the EFL_OPTIONS_SUMMARY() message, use
7# EFL_OPTION_SET_MESSAGE(Name Message) 7# EFL_OPTION_SET_MESSAGE(Name Message)
8macro(EFL_OPTION _name _help _defval) 8macro(EFL_OPTION _name _help _defval)
9 set(_type ${ARGN}) 9 set(_extra_args ${ARGN})
10 if(NOT _type) 10 set(_type)
11 set(_choices)
12 list(LENGTH _extra_args _argc)
13 if(_argc LESS 1)
11 set(_type BOOL) 14 set(_type BOOL)
15 else()
16 list(GET _extra_args 0 _type)
17 list(REMOVE_AT _extra_args 0)
18 endif()
19 if(${_type} STREQUAL "CHOICE")
20 set(_type STRING)
21 set(EFL_OPTION_CHOICES_${_name} ${_extra_args})
22 set(_choices " (Choices: ${_extra_args})")
12 endif() 23 endif()
13 list(APPEND EFL_ALL_OPTIONS ${_name}) 24 list(APPEND EFL_ALL_OPTIONS ${_name})
14 set(EFL_OPTION_DEFAULT_${_name} "${_defval}") 25 set(EFL_OPTION_DEFAULT_${_name} "${_defval}")
15 set(EFL_OPTION_TYPE_${_name} "${_type}") 26 set(EFL_OPTION_TYPE_${_name} "${_type}")
16 set(${_name} ${_defval} CACHE ${_type} "${_help}") 27 set(${_name} ${_defval} CACHE ${_type} "${_help}${_choices}")
17 option(${_name} "${_help}" ${_defval}) 28 option(${_name} "${_help}${_choices}" ${_defval})
29
30 if(_extra_args)
31 list(FIND _extra_args ${${_name}} RET)
32 if(${RET} EQUAL -1)
33 message(FATAL_ERROR "Invalid choice ${_name}=${${_name}}${_choices}")
34 endif()
35 endif()
36
18 unset(_type) 37 unset(_type)
38 unset(_choices)
39 unset(_extra_args)
40 unset(_argc)
19endmacro() 41endmacro()
20 42
21# EFL_OPTION_SET_MESSAGE(Name Message) 43# EFL_OPTION_SET_MESSAGE(Name Message)
@@ -32,7 +54,6 @@ function(EFL_OPTIONS_SUMMARY)
32 message(STATUS "EFL Options Summary:") 54 message(STATUS "EFL Options Summary:")
33 message(STATUS " CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") 55 message(STATUS " CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
34 message(STATUS " CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") 56 message(STATUS " CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
35 message(STATUS " BUILD_PROFILE=${BUILD_PROFILE}")
36 foreach(_o ${EFL_ALL_OPTIONS}) 57 foreach(_o ${EFL_ALL_OPTIONS})
37 set(_v ${${_o}}) 58 set(_v ${${_o}})
38 set(_d ${EFL_OPTION_DEFAULT_${_o}}) 59 set(_d ${EFL_OPTION_DEFAULT_${_o}})
@@ -46,6 +67,19 @@ function(EFL_OPTIONS_SUMMARY)
46 endif() 67 endif()
47 message(STATUS " ${_o}=${_v} (${_i})${_m}") 68 message(STATUS " ${_o}=${_v} (${_i})${_m}")
48 endforeach() 69 endforeach()
70 message(STATUS "EFL Libraries:")
71 foreach(_o ${EFL_ALL_LIBS})
72 message(STATUS " ${_o}${_mods}")
73 foreach(_m ${${_o}_MODULES})
74 string(REGEX REPLACE "^${_o}-module-" "" _m ${_m})
75 message(STATUS " dynamic: ${_m}")
76 endforeach()
77 foreach(_m ${${_o}_STATIC_MODULES})
78 string(REGEX REPLACE "^${_o}-module-" "" _m ${_m})
79 message(STATUS " static.: ${_m}")
80 endforeach()
81 unset(_m)
82 endforeach()
49endfunction() 83endfunction()
50 84
51set(EFL_ALL_LIBS) 85set(EFL_ALL_LIBS)
@@ -158,9 +192,34 @@ macro(EFL_LIB _target)
158 ARCHIVE DESTINATION lib 192 ARCHIVE DESTINATION lib
159 LIBRARY DESTINATION lib) 193 LIBRARY DESTINATION lib)
160 194
195 file(GLOB modules RELATIVE ${EFL_MODULES_SOURCE_DIR} ${EFL_MODULES_SOURCE_DIR}/*)
196 foreach(module ${modules})
197 if(IS_DIRECTORY ${EFL_MODULES_SOURCE_DIR}/${module})
198 set(EFL_MODULE_SCOPE ${module})
199
200 include(${EFL_MODULES_SOURCE_DIR}/${module}/CMakeLists.txt OPTIONAL)
201
202 file(GLOB submodules RELATIVE ${EFL_MODULES_SOURCE_DIR}/${EFL_MODULE_SCOPE} ${EFL_MODULES_SOURCE_DIR}/${EFL_MODULE_SCOPE}/*)
203 foreach(submodule ${submodules})
204 if(IS_DIRECTORY ${EFL_MODULES_SOURCE_DIR}/${EFL_MODULE_SCOPE}/${submodule})
205 EFL_MODULE(${submodule})
206 endif()
207 unset(submodule)
208 unset(submodules)
209 endforeach()
210 else()
211 set(EFL_MODULE_SCOPE)
212 EFL_MODULE(${module})
213 endif()
214 unset(EFL_MODULE_SCOPE)
215 endforeach()
216 unset(module)
217 unset(modules)
218
161 foreach(t ${${_target}_TESTS}) 219 foreach(t ${${_target}_TESTS})
162 EFL_TEST(${t}) 220 EFL_TEST(${t})
163 endforeach() 221 endforeach()
222 unset(t)
164 add_custom_target(${_target}-tests DEPENDS ${${_target}_TESTS}) 223 add_custom_target(${_target}-tests DEPENDS ${${_target}_TESTS})
165 add_custom_target(${_target}-modules DEPENDS ${${_target}_MODULES}) 224 add_custom_target(${_target}-modules DEPENDS ${${_target}_MODULES})
166 list(APPEND EFL_ALL_LIBS ${_target}) 225 list(APPEND EFL_ALL_LIBS ${_target})
@@ -220,13 +279,15 @@ function(EFL_TEST _testname)
220 list(APPEND _deps "${EFL_TESTS_BINARY_DIR}/${f}") 279 list(APPEND _deps "${EFL_TESTS_BINARY_DIR}/${f}")
221 endif() 280 endif()
222 endforeach() 281 endforeach()
223 # TODO: depend on modules! 282 add_dependencies(${_testname} ${EFL_LIB_CURRENT}-modules)
224 set_target_properties(${_testname} PROPERTIES OBJECT_DEPENDS "${_deps}") 283 set_target_properties(${_testname} PROPERTIES OBJECT_DEPENDS "${_deps}")
225 message(STATUS "${_testname} ${_deps}")
226 284
227 target_include_directories(${_testname} SYSTEM PUBLIC 285 target_include_directories(${_testname} PRIVATE
228 ${EFL_TESTS_SOURCE_DIR} 286 ${EFL_TESTS_SOURCE_DIR}
229 ${EFL_TESTS_BINARY_DIR} 287 ${EFL_TESTS_BINARY_DIR}
288 ${${_testname}_INCLUDE_DIRECTORIES})
289 target_include_directories(${_testname} SYSTEM PRIVATE
290 ${${_testname}_SYSTEM_INCLUDE_DIRECTORIES}
230 ${CHECK_INCLUDE_DIRS}) 291 ${CHECK_INCLUDE_DIRS})
231 target_link_libraries(${_testname} 292 target_link_libraries(${_testname}
232 ${EFL_LIB_CURRENT} 293 ${EFL_LIB_CURRENT}
@@ -251,3 +312,118 @@ function(EFL_TEST _testname)
251 312
252 add_test(NAME ${_testname} COMMAND ${_testname}) 313 add_test(NAME ${_testname} COMMAND ${_testname})
253endfunction() 314endfunction()
315
316# EFL_MODULE(Name)
317#
318# Adds a module for ${EFL_LIB_CURRENT} using
319# ${EFL_MODULES_SOURCE_DIR} and ${EFL_MODULES_BINARY_DIR}
320# as well as ${EFL_MODULE_SCOPE} if it's contained into
321# a subdir, such as eina's "mp" or evas "engines".
322#
323# To keep it simple to use, user is only expected to define variables:
324# - SOURCES
325# - DEPENDENCIES
326# - LIBRARIES
327# - INCLUDE_DIRECTORIES
328# - SYSTEM_INCLUDE_DIRECTORIES
329# - DEFINITIONS
330#
331# NOTE: since the file will be included it shouldn't mess with global variables!
332function(EFL_MODULE _modname)
333 if(EFL_MODULE_SCOPE)
334 set(_modsrcdir ${EFL_MODULES_SOURCE_DIR}/${EFL_MODULE_SCOPE}/${_modname})
335 else()
336 set(_modsrcdir ${EFL_MODULES_SOURCE_DIR}/${_modname})
337 endif()
338
339 set(SOURCES)
340 set(DEPENDENCIES)
341 set(LIBRARIES)
342 set(INCLUDE_DIRECTORIES)
343 set(SYSTEM_INCLUDE_DIRECTORIES)
344 set(DEFINITIONS)
345 set(MODULE_TYPE "ON")
346
347 include(${_modsrcdir}/CMakeLists.txt)
348
349 if(NOT SOURCES)
350 message(WARNING "${_modsrcdir}/CMakeLists.txt defines no SOURCES")
351 return()
352 endif()
353
354 if(EFL_MODULE_SCOPE)
355 set(_modbindir ${EFL_MODULES_BINARY_DIR}/${EFL_MODULE_SCOPE}/${_modname})
356 set(_modtarget ${EFL_LIB_CURRENT}-module-${EFL_MODULE_SCOPE}-${_modname})
357 set(_modoutdir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EFL_LIB_CURRENT}/modules/${EFL_MODULE_SCOPE}/${_modname}/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
358 else()
359 set(_modbindir ${EFL_MODULES_BINARY_DIR}/${_modname})
360 set(_modtarget ${EFL_LIB_CURRENT}-module-${_modname})
361 set(_modoutdir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EFL_LIB_CURRENT}/modules/${_modname}/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
362 endif()
363
364 if("${MODULE_TYPE}" STREQUAL "OFF")
365 message(WARNING "${_modsrcdir} disabled")
366 return()
367 elseif("${MODULE_TYPE}" STREQUAL "STATIC")
368 set(_modtype STATIC)
369 else()
370 set(_modtype MODULE)
371 endif()
372
373 set(_sources "")
374 foreach(f ${SOURCES})
375 if(EXISTS "${_modsrcdir}/${f}")
376 list(APPEND _sources "${_modsrcdir}/${f}")
377 else()
378 list(APPEND _sources "${_modbindir}/${f}")
379 endif()
380 endforeach()
381
382 set(_deps "")
383 foreach(f ${DEPENDENCIES})
384 if(EXISTS "${_modsrcdir}/${f}")
385 list(APPEND _deps "${_modsrcdir}/${f}")
386 else()
387 list(APPEND _deps "${_modbindir}/${f}")
388 endif()
389 endforeach()
390
391 add_library(${_modtarget} ${_modtype} ${_sources})
392 set_target_properties(${_modtarget} PROPERTIES
393 OBJECT_DEPENDS "${_deps}"
394 PREFIX ""
395 OUTPUT_NAME "module")
396
397 target_include_directories(${_modtarget} PRIVATE
398 ${_modsrcdir}
399 ${_modbindir}
400 ${INCLUDE_DIRECTORIES})
401 target_include_directories(${_modtarget} SYSTEM PUBLIC
402 ${SYSTEM_INCLUDE_DIRECTORIES})
403 target_link_libraries(${_modtarget} ${LIBRARIES})
404
405 target_compile_definitions(${_modtarget} PRIVATE ${DEFINITIONS})
406
407 set_target_properties(${_modtarget} PROPERTIES
408 LIBRARY_OUTPUT_DIRECTORY "${_modoutdir}"
409 ARCHIVE_OUTPUT_DIRECTORY "${_modoutdir}"
410 RUNTIME_OUTPUT_DIRECTORY "${_modoutdir}")
411
412 if("${MODULE_TYPE}" STREQUAL "STATIC")
413 target_link_libraries(${EFL_LIB_CURRENT} ${_modtarget})
414 target_include_directories(${_modtarget} PRIVATE
415 ${EFL_LIB_SOURCE_DIR}
416 ${EFL_LIB_BINARY_DIR})
417 set_target_properties(${_modtarget} PROPERTIES
418 POSITION_INDEPENDENT_CODE TRUE)
419
420 set(_all_mods ${${EFL_LIB_CURRENT}_STATIC_MODULES})
421 list(APPEND _all_mods ${_modtarget})
422 set(${EFL_LIB_CURRENT}_STATIC_MODULES ${_all_mods} PARENT_SCOPE)
423 else()
424 set(_all_mods ${${EFL_LIB_CURRENT}_MODULES})
425 list(APPEND _all_mods ${_modtarget})
426 set(${EFL_LIB_CURRENT}_MODULES ${_all_mods} PARENT_SCOPE)
427 target_link_libraries(${_modtarget} ${EFL_LIB_CURRENT})
428 endif()
429endfunction()
diff --git a/src/lib/efl/config.h.cmake b/src/lib/efl/config.h.cmake
index 4cd524ab1c..277a78d57b 100644
--- a/src/lib/efl/config.h.cmake
+++ b/src/lib/efl/config.h.cmake
@@ -12,6 +12,10 @@
12#cmakedefine NVALGRIND 1 12#cmakedefine NVALGRIND 1
13#cmakedefine HAVE_CLOCK_GETTIME 1 13#cmakedefine HAVE_CLOCK_GETTIME 1
14 14
15#cmakedefine EINA_STATIC_BUILD_CHAINED_POOL 1
16#cmakedefine EINA_STATIC_BUILD_ONE_BIG 1
17#cmakedefine EINA_STATIC_BUILD_PASS_THROUGH 1
18
15#define PACKAGE_LIB_DIR "bla" 19#define PACKAGE_LIB_DIR "bla"
16#define MODULE_ARCH "bla" 20#define MODULE_ARCH "bla"
17#define SHARED_LIB_SUFFIX "bla" 21#define SHARED_LIB_SUFFIX "bla"
diff --git a/src/modules/eina/CMakeLists.txt b/src/modules/eina/CMakeLists.txt
deleted file mode 100644
index 493816291e..0000000000
--- a/src/modules/eina/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
1include_directories(
2${PROJECT_SOURCE_DIR}/
3${PROJECT_SOURCE_DIR}/src/lib/eina
4${PROJECT_SOURCE_DIR}/src/lib/efl
5${VG_INCLUDE_DIRS}
6)
7
8if (EINA_STATIC_BUILD_PASS_THROUGH)
9 add_library(pass_through MODULE "mp/pass_through/eina_pass_through.c")
10endif(EINA_STATIC_BUILD_PASS_THROUGH)
11
12
13if (EINA_STATIC_BUILD_ONE_BIG)
14 add_library(one_big MODULE mp/one_big/eina_one_big.c)
15endif(EINA_STATIC_BUILD_ONE_BIG)
16
17
18if (EINA_STATIC_BUILD_CHAINED_POOL)
19 add_library(chained_pool MODULE mp/chained_pool/eina_chained_mempool.c)
20endif(EINA_STATIC_BUILD_CHAINED_POOL) \ No newline at end of file
diff --git a/src/modules/eina/mp/chained_pool/CMakeLists.txt b/src/modules/eina/mp/chained_pool/CMakeLists.txt
new file mode 100644
index 0000000000..1fb1dd57d8
--- /dev/null
+++ b/src/modules/eina/mp/chained_pool/CMakeLists.txt
@@ -0,0 +1,2 @@
1set(MODULE_TYPE ${EINA_BUILD_CHAINED})
2set(SOURCES eina_chained_mempool.c)
diff --git a/src/modules/eina/mp/one_big/CMakeLists.txt b/src/modules/eina/mp/one_big/CMakeLists.txt
new file mode 100644
index 0000000000..42a3929838
--- /dev/null
+++ b/src/modules/eina/mp/one_big/CMakeLists.txt
@@ -0,0 +1,2 @@
1set(MODULE_TYPE ${EINA_BUILD_ONE_BIG})
2set(SOURCES eina_one_big.c)
diff --git a/src/modules/eina/mp/pass_through/CMakeLists.txt b/src/modules/eina/mp/pass_through/CMakeLists.txt
new file mode 100644
index 0000000000..f863843b7c
--- /dev/null
+++ b/src/modules/eina/mp/pass_through/CMakeLists.txt
@@ -0,0 +1,2 @@
1set(MODULE_TYPE ${EINA_BUILD_PASS_THROUGH})
2set(SOURCES eina_pass_through.c)