CMake: rework to use some helper macros.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Thu, 19 Jan 2017 19:54:12 +0000 (17:54 -0200)
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>
Mon, 23 Jan 2017 17:23:40 +0000 (18:23 +0100)
This tries to defines some macros to create a cleaner build system.

.gitignore
CMakeLists.txt
cmake/config/common.cmake [new file with mode: 0644]
cmake/config/eina.cmake [new file with mode: 0644]
cmake/helpers/EflMacros.cmake [new file with mode: 0644]
src/lib/efl/.gitignore
src/lib/efl/config.h.cmake [moved from config.h.cmake with 80% similarity]
src/lib/eina/CMakeLists.txt
src/tests/eina/CMakeLists.txt

index ac86fdc..25bf616 100644 (file)
@@ -81,3 +81,6 @@ Session.vim
 #wayland generated protocol - some legacy headers will be ignored
 *-protocol.h
 *-protocol.c
+
+/build
+
index 12dd0a8..f68a811 100644 (file)
@@ -1,19 +1,44 @@
 cmake_minimum_required(VERSION 3.7)
-project(eflgeneric)
+project(efl VERSION 1.19.99.1)
+if (NOT EFL_BUILD_ID)
+  set(EFL_BUILD_ID 120)
+endif()
 
-ADD_DEFINITIONS("-DHAVE_CONFIG_H")
+if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
+  message(FATAL_ERROR "In-source builds not allowed. Use: mkdir -p build && cmake -H. -Bbuild")
+endif()
 
-add_subdirectory(src)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Path to store built libraries")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Path to store built executables")
 
-CHECK_INCLUDE_FILE(sys/mman.h HAVE_SYS_MMAN_H)
+set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Absolute path to library installation directory")
+set(EXEC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Absolute path to executable installation directory")
+set(HEADER_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Absolute path to install headers by the library")
 
-set(PROJECT_VERSION_MAJOR 1)
-set(PROJECT_VERSION_MINOR 19)
-set(PROJECT_VERSION_PATCH 99)
-set(PROJECT_VERSION_TWEAK 00)
+add_definitions(
+  "-DHAVE_CONFIG_H"
+  "-DLIB_INSTALL_DIR=\"${LIB_INSTALL_DIR}\""
+  "-DEXEC_INSTALL_DIR=\"${EXEC_INSTALL_DIR}\""
+  )
+include_directories(
+  ${PROJECT_SOURCE_DIR}/src/lib/efl
+  ${PROJECT_BINARY_DIR}/src/lib/efl
+  )
 
-set(VMAJ ${PROJECT_VERSION_MAJOR})
-set(VMIN ${PROJECT_VERSION_MINOR})
-set(VMIC ${PROJECT_VERSION_PATCH})
-set(VREV ${PROJECT_VERSION_TWEAK})
-configure_file(config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/helpers")
+include(EflMacros)
+
+include(${CMAKE_SOURCE_DIR}/cmake/config/common.cmake)
+
+EFL_LIB(eina)
+
+EFL_OPTIONS_SUMMARY()
+
+configure_file(
+  ${PROJECT_SOURCE_DIR}/src/lib/efl/config.h.cmake
+  ${PROJECT_BINARY_DIR}/src/lib/efl/config.h)
+configure_file(
+  ${PROJECT_SOURCE_DIR}/src/lib/efl/Efl_Config.h.cmake
+  ${PROJECT_BINARY_DIR}/src/lib/efl/Efl_Config.h)
+
+EFL_FINALIZE()
diff --git a/cmake/config/common.cmake b/cmake/config/common.cmake
new file mode 100644 (file)
index 0000000..f411662
--- /dev/null
@@ -0,0 +1,30 @@
+include(CheckSymbolExists)
+include(CheckIncludeFile)
+include(CheckTypeSize)
+include(FindPkgConfig)
+include(CTest)
+find_package(Threads REQUIRED)
+
+pkg_check_modules(CHECK check)
+
+CHECK_INCLUDE_FILE(sys/mman.h HAVE_SYS_MMAN_H)
+
+set(VMAJ ${PROJECT_VERSION_MAJOR})
+set(VMIN ${PROJECT_VERSION_MINOR})
+set(VMIC ${PROJECT_VERSION_PATCH})
+set(VREV ${PROJECT_VERSION_TWEAK})
+set(EFL_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
+set(EFL_VERSION_MINOR ${PROJECT_VERSION_MINOR})
+
+set(BUILD_ALL_PROFILES release dev debug)
+EFL_OPTION(BUILD_PROFILE "How to build EFL (one of: ${BUILD_ALL_PROFILES})" "release" STRING)
+list(FIND BUILD_ALL_PROFILES ${BUILD_PROFILE} RET)
+if (${RET} EQUAL -1)
+  message(FATAL_ERROR "Unknown BUILD_PROFILE=${BUILD_PROFILE}")
+endif()
+
+EFL_OPTION(EFL_NOLEGACY_API_SUPPORT "Whenever to disable non-Eo (Legacy) APIs" ON)
+EFL_OPTION(EFL_EO_API_SUPPORT "Whenever to enable new Eo APIs" ON)
+if(NOT EFL_EO_API_SUPPORT)
+  EFL_OPTION_SET_MESSAGE(EFL_EO_API_SUPPORT "Risky!")
+endif()
diff --git a/cmake/config/eina.cmake b/cmake/config/eina.cmake
new file mode 100644 (file)
index 0000000..3614880
--- /dev/null
@@ -0,0 +1,64 @@
+set(EINA_SAFETY_CHECKS 1)
+set(EINA_DEBUG_THREADS OFF)
+set(VALGRIND OFF)
+if("${BUILD_PROFILE}" STREQUAL "dev")
+  set(EINA_STRINGSHARE_USAGE ON)
+  set(CHECK_VALGRIND ON)
+elseif("${BUILD_PROFILE}" STREQUAL "debug")
+  set(EINA_DEBUG_MALLOC ON)
+  set(EINA_COW_MAGIC_ON ON)
+  set(EINA_DEFAULT_MEMPOOL ON)
+  set(EINA_DEBUG_MALLOC ON)
+  set(EINA_DEBUG_THREADS ON)
+  set(VALGRIND ON)
+elseif("${BUILD_PROFILE}" STREQUAL "release")
+  set(EINA_LOG_LEVEL_MAXIMUM 3)
+endif()
+
+EFL_OPTION(EINA_MAGIC_DEBUG "magic debug of eina structure" ON)
+EFL_OPTION(EINA_DEBUG_THREADS "debugging of eina threads" ${EINA_DEBUG_THREADS})
+EFL_OPTION(VALGRIND "valgrind support" ${VALGRIND})
+
+
+#check for symbols in pthread
+#TODO Make the definitions depending on the platform
+set(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
+set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE=1")
+CHECK_SYMBOL_EXISTS(pthread_barrier_init pthread.h EINA_HAVE_PTHREAD_BARRIER)
+CHECK_SYMBOL_EXISTS(pthread_attr_setaffinity_np pthread.h EINA_HAVE_PTHREAD_AFFINITY)
+CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h EINA_HAVE_PTHREAD_SETNAME)
+CHECK_SYMBOL_EXISTS(pthread_spin_init pthread.h EINA_HAVE_POSIX_SPINLOCK)
+
+#check for eina header files that are required
+CHECK_INCLUDE_FILE(alloca.h EINA_HAVE_ALLOCA_H)
+CHECK_INCLUDE_FILE(byteswap.h EINA_HAVE_BYTESWAP_H)
+CHECK_INCLUDE_FILE(fnmatch.h EINA_HAVE_FNMATCH_H)
+#only enable log when fnmatch is there
+if (EINA_HAVE_FNMATCH_H)
+  set(EINA_ENABLE_LOG 1)
+endif (EINA_HAVE_FNMATCH_H)
+CHECK_INCLUDE_FILE(dirent.h EINA_HAVE_DIRENT_H)
+
+CHECK_TYPE_SIZE("wchar_t" EINA_SIZEOF_WCHAR_T)
+CHECK_TYPE_SIZE("uintptr_t" EINA_SIZEOF_UINTPTR_T)
+CHECK_TYPE_SIZE("wchar_t" EINA_SIZEOF_WCHAR_T)
+
+#check for swap16/32/64
+CHECK_SYMBOL_EXISTS(bswap_16 byteswap.h EINA_HAVE_BSWAP16)
+CHECK_SYMBOL_EXISTS(bswap_32 byteswap.h EINA_HAVE_BSWAP32)
+CHECK_SYMBOL_EXISTS(bswap_64 byteswap.h EINA_HAVE_BSWAP64)
+
+CHECK_SYMBOL_EXISTS(clock_gettime time.h HAVE_CLOCK_GETTIME)
+
+if(VALGRIND)
+  pkg_check_modules(VG REQUIRED valgrind)
+  set(NVALGRIND OFF)
+else()
+  set(NVALGRIND ON)
+endif()
+
+#Check if there is the alloca header
+
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/eina/eina_config.h.cmake
+  ${CMAKE_CURRENT_BINARY_DIR}/src/lib/eina/eina_config.h)
diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake
new file mode 100644 (file)
index 0000000..cb5d3e5
--- /dev/null
@@ -0,0 +1,253 @@
+# EFL_OPTION(Name Help Default)
+#
+# Declare an option() that will be automatically printed by
+# EFL_OPTIONS_SUMMARY()
+#
+# To extend the EFL_OPTIONS_SUMMARY() message, use
+# EFL_OPTION_SET_MESSAGE(Name Message)
+macro(EFL_OPTION _name _help _defval)
+  set(_type ${ARGN})
+  if(NOT _type)
+    set(_type BOOL)
+  endif()
+  list(APPEND EFL_ALL_OPTIONS ${_name})
+  set(EFL_OPTION_DEFAULT_${_name} "${_defval}")
+  set(EFL_OPTION_TYPE_${_name} "${_type}")
+  set(${_name} ${_defval} CACHE ${_type} "${_help}")
+  option(${_name} "${_help}" ${_defval})
+  unset(_type)
+endmacro()
+
+# EFL_OPTION_SET_MESSAGE(Name Message)
+#
+# Extends the summary line output by EFL_OPTIONS_SUMMARY()
+# with more details.
+macro(EFL_OPTION_SET_MESSAGE _name _message)
+  set(EFL_OPTION_MESSAGE_${_name} "${_message}")
+endmacro()
+
+# EFL_OPTIONS_SUMMARY()
+# Shows the summary of options, their values and related messages.
+function(EFL_OPTIONS_SUMMARY)
+  message(STATUS "EFL Options Summary:")
+  message(STATUS "  CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
+  message(STATUS "  CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
+  message(STATUS "  BUILD_PROFILE=${BUILD_PROFILE}")
+  foreach(_o ${EFL_ALL_OPTIONS})
+    set(_v ${${_o}})
+    set(_d ${EFL_OPTION_DEFAULT_${_o}})
+    if("${_v}" STREQUAL "${_d}")
+      set(_i "default")
+    else()
+      set(_i "default: ${_d}")
+    endif()
+    if(EFL_OPTION_MESSAGE_${_o})
+      set(_m " [${EFL_OPTION_MESSAGE_${_o}}]")
+    endif()
+    message(STATUS "  ${_o}=${_v} (${_i})${_m}")
+  endforeach()
+endfunction()
+
+set(EFL_ALL_LIBS)
+set(EFL_ALL_TESTS)
+
+macro(EFL_FINALIZE)
+  add_custom_target(all-libs DEPENDS ${EFL_ALL_LIBS})
+  add_custom_target(all-tests DEPENDS ${EFL_ALL_TESTS})
+endmacro()
+
+# EFL_LIB(Name)
+#
+# adds a library ${Name} automatically setting:
+#  - target_include_directories to ${Name}_INCLUDE_DIRECTORIES
+#  - target_include_directories(SYSTEM) to ${Name}_SYSTEM_INCLUDE_DIRECTORIES
+#  - OUTPUT_NAME to ${Name}_OUTPUT_NAME
+#  - SOURCES to ${Name}_SOURCES
+#  - HEADER to ${Name}_HEADERS (to be installed)
+#  - VERSION to ${Name}_VERSION (defaults to project version)
+#  - SOVERSION to ${Name}_SOURCES (defaults to project major version)
+#  - OBJECT_DEPENDS to ${Name}_DEPENDENCIES
+#  - target_link_libraries() to ${Name}_LIBRARIES
+#  - target_compile_definitions() to ${Name}_DEFINITIONS
+#  - compile tests in ${Name}_TESTS using EFL_TEST()
+#
+macro(EFL_LIB _target)
+  string(TOLOWER ${_target} _target_lc)
+  set(EFL_LIB_CURRENT ${_target})
+  set(EFL_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/${_target_lc})
+  set(EFL_LIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/lib/${_target_lc})
+  set(EFL_BIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/bin/${_target_lc})
+  set(EFL_BIN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/bin/${_target_lc})
+  set(EFL_MODULES_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/modules/${_target_lc})
+  set(EFL_MODULES_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/modules/${_target_lc})
+  set(EFL_TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/tests/${_target_lc})
+  set(EFL_TESTS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/tests/${_target_lc})
+
+  set(${_target}_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
+  set(${_target}_SOVERSION ${PROJECT_VERSION_MAJOR})
+  set(${_target}_LIBRARY_TYPE SHARED)
+
+  include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config/${_target_lc}.cmake OPTIONAL)
+  include(${EFL_LIB_SOURCE_DIR}/CMakeLists.txt OPTIONAL)
+  include(${EFL_BIN_SOURCE_DIR}/CMakeLists.txt OPTIONAL)
+  include(${EFL_MODULES_SOURCE_DIR}/CMakeLists.txt OPTIONAL)
+  include(${EFL_TESTS_SOURCE_DIR}/CMakeLists.txt OPTIONAL)
+
+  set(_headers "")
+  foreach(f ${${_target}_HEADERS})
+    if(EXISTS "${EFL_LIB_SOURCE_DIR}/${f}")
+      list(APPEND _headers "${EFL_LIB_SOURCE_DIR}/${f}")
+    else()
+      list(APPEND _headers "${EFL_LIB_BINARY_DIR}/${f}")
+    endif()
+  endforeach()
+
+  set(_sources "")
+  foreach(f ${${_target}_SOURCES})
+    if(EXISTS "${EFL_LIB_SOURCE_DIR}/${f}")
+      list(APPEND _sources "${EFL_LIB_SOURCE_DIR}/${f}")
+    else()
+      list(APPEND _sources "${EFL_LIB_BINARY_DIR}/${f}")
+    endif()
+  endforeach()
+
+  set(_deps "")
+  foreach(f ${${_target}_DEPENDENCIES})
+    if(EXISTS "${EFL_LIB_SOURCE_DIR}/${f}")
+      list(APPEND _deps "${EFL_LIB_SOURCE_DIR}/${f}")
+    else()
+      list(APPEND _deps "${EFL_LIB_BINARY_DIR}/${f}")
+    endif()
+  endforeach()
+
+  add_library(${_target} ${${_target}_LIBRARY_TYPE} ${_sources} ${_headers})
+  set_target_properties(${_target} PROPERTIES
+    FRAMEWORK TRUE
+    PUBLIC_HEADER "${_headers}"
+    OBJECT_DEPENDS "${_deps}")
+
+  if(${_target}_LIBRARIES)
+    target_link_libraries(${_target} ${${_target}_LIBRARIES})
+  endif()
+
+  target_include_directories(${_target} PUBLIC
+    ${${_target}_INCLUDE_DIRECTORIES}
+    ${EFL_LIB_SOURCE_DIR}
+    )
+  if(${_target}_SYSTEM_INCLUDE_DIRECTORIES)
+    target_include_directories(${_target} SYSTEM PUBLIC ${${_target}_SYSTEM_INCLUDE_DIRECTORIES})
+  endif()
+
+  if(${_target}_DEFINITIONS)
+    target_compile_definitions(${_target} PRIVATE ${${_target}_DEFINITIONS})
+  endif()
+
+  if(${_target}_OUTPUT_NAME)
+    set_target_properties(${_target} PROPERTIES OUTPUT_NAME ${${_target}_OUTPUT_NAME})
+  endif()
+
+  if(${_target}_VERSION AND ${_target}_SOVERSION)
+    set_target_properties(${_target} PROPERTIES
+      VERSION ${${_target}_VERSION}
+      SOVERSION ${${_target}_SOVERSION})
+  endif()
+
+  install(TARGETS ${_target}
+    PUBLIC_HEADER DESTINATION include/${_target}-${PROJECT_VERSION_MAJOR}
+    RUNTIME DESTINATION bin
+    ARCHIVE DESTINATION lib
+    LIBRARY DESTINATION lib)
+
+  foreach(t ${${_target}_TESTS})
+    EFL_TEST(${t})
+  endforeach()
+  add_custom_target(${_target}-tests DEPENDS ${${_target}_TESTS})
+  add_custom_target(${_target}-modules DEPENDS ${${_target}_MODULES})
+  list(APPEND EFL_ALL_LIBS ${_target})
+  list(APPEND EFL_ALL_TESTS ${_target}-tests)
+
+  unset(_sources)
+  unset(_headers)
+  unset(_deps)
+  unset(EFL_LIB_CURRENT)
+  unset(EFL_LIB_SOURCE_DIR)
+  unset(EFL_LIB_BINARY_DIR)
+  unset(EFL_BIN_SOURCE_DIR)
+  unset(EFL_BIN_BINARY_DIR)
+  unset(EFL_MODULES_SOURCE_DIR)
+  unset(EFL_MODULES_BINARY_DIR)
+  unset(EFL_TESTS_SOURCE_DIR)
+  unset(EFL_TESTS_BINARY_DIR)
+endmacro()
+
+
+# EFL_TEST(Name)
+#
+# Adds a test for ${EFL_LIB_CURRENT} using
+# ${EFL_TESTS_SOURCE_DIR} and ${EFL_TESTS_BINARY_DIR}
+#
+# Settings:
+#  - include_directories to ${Name}_INCLUDE_DIRECTORIES
+#  - include_directories(SYSTEM) to ${Name}_SYSTEM_INCLUDE_DIRECTORIES
+#  - OUTPUT_NAME to ${Name}_OUTPUT_NAME
+#  - SOURCES to ${Name}_SOURCES
+#  - target_link_libraries() to ${Name}_LIBRARIES (${EFL_LIB_CURRENT}
+#    is automatic)
+#  - target_compile_definitions() to ${Name}_DEFINITIONS
+#
+# NOTE: it's meant to be called by files included by EFL_LIB() or similar,
+# otherwise you need to prepare the environment yourself.
+function(EFL_TEST _testname)
+  if(NOT CHECK_FOUND)
+    message(STATUS "${EFL_LIB_CURRENT} test ${_testname} ignored since no 'check' library was found.")
+    return()
+  endif()
+  set(_sources "")
+  foreach(f ${${_testname}_SOURCES})
+    if(EXISTS "${EFL_TESTS_SOURCE_DIR}/${f}")
+      list(APPEND _sources "${EFL_TESTS_SOURCE_DIR}/${f}")
+    else()
+      list(APPEND _sources "${EFL_TESTS_BINARY_DIR}/${f}")
+    endif()
+  endforeach()
+  add_executable(${_testname} EXCLUDE_FROM_ALL ${_sources})
+
+  set(_deps "")
+  foreach(f ${${_testname}_DEPENDENCIES})
+    if(EXISTS "${EFL_TESTS_SOURCE_DIR}/${f}")
+      list(APPEND _deps "${EFL_TESTS_SOURCE_DIR}/${f}")
+    else()
+      list(APPEND _deps "${EFL_TESTS_BINARY_DIR}/${f}")
+    endif()
+  endforeach()
+  # TODO: depend on modules!
+  set_target_properties(${_testname} PROPERTIES OBJECT_DEPENDS "${_deps}")
+  message(STATUS "${_testname} ${_deps}")
+
+  target_include_directories(${_testname} SYSTEM PUBLIC
+    ${EFL_TESTS_SOURCE_DIR}
+    ${EFL_TESTS_BINARY_DIR}
+    ${CHECK_INCLUDE_DIRS})
+  target_link_libraries(${_testname}
+    ${EFL_LIB_CURRENT}
+    ${${_testname}_LIBRARIES}
+    ${CHECK_LIBRARIES})
+
+  target_compile_definitions(${_testname} PRIVATE
+    "-DTESTS_SRC_DIR=\"${EFL_TESTS_SOURCE_DIR}\""
+    "-DTESTS_BUILD_DIR=\"${EFL_TESTS_BINARY_DIR}\""
+    "-DTESTS_WD=\"${PROJECT_BINARY_DIR}\""
+    "-DPACKAGE_BUILD_DIR=\"1\""
+    ${${_testname}_DEFINITIONS}
+    )
+
+  if(${_testname}_OUTPUT_NAME)
+    set_target_properties(${_testname} PROPERTIES OUTPUT_NAME ${${_testname}_OUTPUT_NAME})
+  endif()
+
+  set_target_properties(${_testname} PROPERTIES
+    LIBRARY_OUTPUT_DIRECTORY "${EFL_TESTS_BINARY_DIR}"
+    RUNTIME_OUTPUT_DIRECTORY "${EFL_TESTS_BINARY_DIR}")
+
+  add_test(NAME ${_testname} COMMAND ${_testname})
+endfunction()
similarity index 80%
rename from config.h.cmake
rename to src/lib/efl/config.h.cmake
index ca8a2bd..4cd524a 100644 (file)
@@ -9,8 +9,11 @@
 #cmakedefine VMIC @VMIC@
 #cmakedefine VREV @VREV@
 
+#cmakedefine NVALGRIND 1
+#cmakedefine HAVE_CLOCK_GETTIME 1
+
 #define PACKAGE_LIB_DIR "bla"
 #define MODULE_ARCH "bla"
 #define SHARED_LIB_SUFFIX "bla"
 
-#endif
\ No newline at end of file
+#endif
index 56b6f67..8e08a49 100644 (file)
-INCLUDE (CheckSymbolExists)
-INCLUDE (CheckIncludeFile)
-INCLUDE (CheckTypeSize)
-INCLUDE (FindPkgConfig)
-find_package(Threads REQUIRED)
 
-#Configure depending on the profile
-set(EINA_SAFETY_CHECKS 1)
-if ("${BUILD_PROFILE}" STREQUAL "dev")
-    set(EINA_STRINGSHARE_USAGE ON)
-    set(CHECK_VALGRIND ON)
-elseif ("${BUILD_PROFILE}" STREQUAL "debug")
-    set(EINA_DEBUG_MALLOC ON)
-    set(EINA_COW_MAGIC_ON ON)
-    set(EINA_DEFAULT_MEMPOOL ON)
-    set(EINA_DEBUG_MALLOC ON)
-    set(EINA_DEBUG_THREADS ON)
-    set(VALGRIND ON)
-elseif ("${BUILD_PROFILE}" STREQUAL "release")
-    set(EINA_LOG_LEVEL_MAXIMUM 3)
-endif ("${BUILD_PROFILE}" STREQUAL "dev")
+set(eina_INCLUDE_DIRECTORIES ${VG_INCLUDE_DIRS})
 
-#options of that submodule
-option(EINA_MAGIC_DEBUG "magic debug of eina structure" ON)
-option(EINA_DEBUG_THREADS "debugging of eina threads" ${EINA_DEBUG_THREADS})
-option(VALGRIND "valgrind support" ${VALGRIND})
+set(eina_LIBRARIES
+  ${VG_LIBRARIES}
+  pthread)
 
-#check for symbols in pthread
-#TODO Make the definitions depending on the platform
-set(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
-set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE=1")
-CHECK_SYMBOL_EXISTS(pthread_barrier_init pthread.h EINA_HAVE_PTHREAD_BARRIER)
-CHECK_SYMBOL_EXISTS(pthread_attr_setaffinity_np pthread.h EINA_HAVE_PTHREAD_AFFINITY)
-CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h EINA_HAVE_PTHREAD_SETNAME)
-CHECK_SYMBOL_EXISTS(pthread_spin_init pthread.h EINA_HAVE_POSIX_SPINLOCK)
+set(eina_HEADERS
+  Eina.h
+  eina_accessor.h
+  eina_alloca.h
+  eina_array.h
+  eina_benchmark.h
+  eina_bezier.h
+  eina_binbuf.h
+  eina_binshare.h
+  eina_clist.h
+  eina_config.h
+  eina_convert.h
+  eina_counter.h
+  eina_cow.h
+  eina_cpu.h
+  eina_crc.h
+  eina_debug.h
+  eina_error.h
+  eina_evlog.h
+  eina_file.h
+  eina_file_common.h
+  eina_fp.h
+  eina_freeq.h
+  eina_hamster.h
+  eina_hash.h
+  eina_inarray.h
+  eina_inline_private.h
+  eina_inlist.h
+  eina_iterator.h
+  eina_lalloc.h
+  eina_list.h
+  eina_lock.h
+  eina_log.h
+  eina_magic.h
+  eina_main.h
+  eina_matrix.h
+  eina_matrixsparse.h
+  eina_mempool.h
+  eina_mmap.h
+  eina_module.h
+  eina_prefix.h
+  eina_private.h
+  eina_quad.h
+  eina_quadtree.h
+  eina_quaternion.h
+  eina_rbtree.h
+  eina_rectangle.h
+  eina_refcount.h
+  eina_safepointer.h
+  eina_safety_checks.h
+  eina_sched.h
+  eina_share_common.h
+  eina_simple_xml_parser.h
+  eina_slice.h
+  eina_slstr.h
+  eina_str.h
+  eina_strbuf.h
+  eina_strbuf_common.h
+  eina_strbuf_template_c.x
+  eina_stringshare.h
+  eina_thread.h
+  eina_thread_queue.h
+  eina_tiler.h
+  eina_tmpstr.h
+  eina_trash.h
+  eina_types.h
+  eina_unicode.h
+  eina_ustrbuf.h
+  eina_ustringshare.h
+  eina_util.h
+  eina_value.h
+  eina_value_util.h
+  eina_vector.h
+  eina_xattr.h
+  )
 
-#check for eina header files that are required
-CHECK_INCLUDE_FILE(alloca.h EINA_HAVE_ALLOCA_H)
-CHECK_INCLUDE_FILE(byteswap.h EINA_HAVE_BYTESWAP_H)
-CHECK_INCLUDE_FILE(fnmatch.h EINA_HAVE_FNMATCH_H)
-#only enable log when fnmatch is there
-if (EINA_HAVE_FNMATCH_H)
-  set(EINA_ENABLE_LOG 1)
-endif (EINA_HAVE_FNMATCH_H)
-CHECK_INCLUDE_FILE(dirent.h EINA_HAVE_DIRENT_H)
-
-CHECK_TYPE_SIZE("wchar_t" EINA_SIZEOF_WCHAR_T)
-CHECK_TYPE_SIZE("uintptr_t" EINA_SIZEOF_UINTPTR_T)
-CHECK_TYPE_SIZE("wchar_t" EINA_SIZEOF_WCHAR_T)
-
-#check for swap16/32/64
-CHECK_SYMBOL_EXISTS(bswap_16 byteswap.h EINA_HAVE_BSWAP16)
-CHECK_SYMBOL_EXISTS(bswap_32 byteswap.h EINA_HAVE_BSWAP32)
-CHECK_SYMBOL_EXISTS(bswap_64 byteswap.h EINA_HAVE_BSWAP64)
-
-#TODO really check if we wanted to have valgrind support or not
-pkg_check_modules(VG REQUIRED valgrind)
-
-#Check if there is the alloca header
-
-configure_file(eina_config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/eina_config.h)
-
-include_directories(
-    ${PROJECT_SOURCE_DIR}/
-    ${VG_INCLUDE_DIRS}
-    ${PROJECT_SOURCE_DIR}/src/lib/efl
-    ${PROJECT_SOURCE_DIR}/src/lib/eina
-)
-
-LIST(APPEND eina_source
-    Eina.h
-    eina_abi.c
-    eina_accessor.c
-    eina_accessor.h
-    eina_alloca.h
-    eina_array.c
-    eina_array.h
-    eina_benchmark.c
-    eina_benchmark.h
-    eina_bezier.c
-    eina_bezier.h
-    eina_binbuf.c
-    eina_binbuf.h
-    eina_binshare.c
-    eina_binshare.h
-    eina_clist.h
-    eina_config.h
-    eina_convert.c
-    eina_convert.h
-    eina_counter.c
-    eina_counter.h
-    eina_cow.c
-    eina_cow.h
-    eina_cpu.c
-    eina_cpu.h
-    eina_crc.c
-    eina_crc.h
-    eina_debug.c
-    eina_debug.h
-    eina_debug_bt.c
-    eina_debug_bt_file.c
-    eina_debug_chunk.c
-    eina_debug_monitor.c
-    eina_debug_proto.c
-    eina_debug_thread.c
-    eina_error.c
-    eina_error.h
-    eina_evlog.c
-    eina_evlog.h
-    eina_file.c
-    eina_file.h
-    eina_file_common.c
-    eina_file_common.h
-    eina_fp.c
-    eina_fp.h
-    eina_freeq.c
-    eina_freeq.h
-    eina_hamster.c
-    eina_hamster.h
-    eina_hash.c
-    eina_hash.h
-    eina_inarray.c
-    eina_inarray.h
-    eina_inline_private.h
-    eina_inlist.c
-    eina_inlist.h
-    eina_iterator.c
-    eina_iterator.h
-    eina_lalloc.c
-    eina_lalloc.h
-    eina_list.c
-    eina_list.h
-    eina_lock.c
-    eina_lock.h
-    eina_log.c
-    eina_log.h
-    eina_magic.c
-    eina_magic.h
-    eina_main.c
-    eina_main.h
-    eina_matrix.c
-    eina_matrix.h
-    eina_matrixsparse.c
-    eina_matrixsparse.h
-    eina_mempool.c
-    eina_mempool.h
-    eina_mmap.c
-    eina_mmap.h
-    eina_module.c
-    eina_module.h
-    eina_prefix.c
-    eina_prefix.h
-    eina_private.h
-    eina_quad.c
-    eina_quad.h
-    eina_quadtree.c
-    eina_quadtree.h
-    eina_quaternion.c
-    eina_quaternion.h
-    eina_rbtree.c
-    eina_rbtree.h
-    eina_rectangle.c
-    eina_rectangle.h
-    eina_refcount.h
-    eina_safepointer.c
-    eina_safepointer.h
-    eina_safety_checks.c
-    eina_safety_checks.h
-    eina_sched.c
-    eina_sched.h
-    eina_share_common.c
-    eina_share_common.h
-    eina_simple_xml_parser.c
-    eina_simple_xml_parser.h
-    eina_slice.h
-    eina_slstr.c
-    eina_slstr.h
-    eina_str.c
-    eina_str.h
-    eina_strbuf.c
-    eina_strbuf.h
-    eina_strbuf_common.c
-    eina_strbuf_common.h
-    eina_strbuf_template_c.x
-    eina_stringshare.c
-    eina_stringshare.h
-    eina_thread.c
-    eina_thread.h
-    eina_thread_queue.c
-    eina_thread_queue.h
-    eina_tiler.c
-    eina_tiler.h
-    eina_tmpstr.c
-    eina_tmpstr.h
-    eina_trash.h
-    eina_types.h
-    eina_unicode.c
-    eina_unicode.h
-    eina_ustrbuf.c
-    eina_ustrbuf.h
-    eina_ustringshare.c
-    eina_ustringshare.h
-    eina_util.c
-    eina_util.h
-    eina_value.c
-    eina_value.h
-    eina_value_util.c
-    eina_value_util.h
-    eina_vector.h
-    eina_xattr.c
-    eina_xattr.h
-)
-
-add_library(eina SHARED ${eina_source})
\ No newline at end of file
+LIST(APPEND eina_SOURCES
+  eina_abi.c
+  eina_accessor.c
+  eina_array.c
+  eina_benchmark.c
+  eina_bezier.c
+  eina_binbuf.c
+  eina_binshare.c
+  eina_convert.c
+  eina_counter.c
+  eina_cow.c
+  eina_cpu.c
+  eina_crc.c
+  eina_debug.c
+  eina_debug_bt.c
+  eina_debug_bt_file.c
+  eina_debug_chunk.c
+  eina_debug_monitor.c
+  eina_debug_proto.c
+  eina_debug_thread.c
+  eina_error.c
+  eina_evlog.c
+  eina_file.c
+  eina_file_common.c
+  eina_fp.c
+  eina_freeq.c
+  eina_hamster.c
+  eina_hash.c
+  eina_inarray.c
+  eina_inlist.c
+  eina_iterator.c
+  eina_lalloc.c
+  eina_list.c
+  eina_lock.c
+  eina_log.c
+  eina_magic.c
+  eina_main.c
+  eina_matrix.c
+  eina_matrixsparse.c
+  eina_mempool.c
+  eina_mmap.c
+  eina_module.c
+  eina_prefix.c
+  eina_quad.c
+  eina_quadtree.c
+  eina_quaternion.c
+  eina_rbtree.c
+  eina_rectangle.c
+  eina_safepointer.c
+  eina_safety_checks.c
+  eina_sched.c
+  eina_share_common.c
+  eina_simple_xml_parser.c
+  eina_slstr.c
+  eina_str.c
+  eina_strbuf.c
+  eina_strbuf_common.c
+  eina_strbuf_template_c.x
+  eina_stringshare.c
+  eina_thread.c
+  eina_thread_queue.c
+  eina_tiler.c
+  eina_tmpstr.c
+  eina_unicode.c
+  eina_ustrbuf.c
+  eina_ustringshare.c
+  eina_util.c
+  eina_value.c
+  eina_value_util.c
+  eina_xattr.c
+  )
index 358f13e..434db48 100644 (file)
@@ -1,69 +1,66 @@
-include_directories(
-    ${PROJECT_SOURCE_DIR}/
-    ${PROJECT_SOURCE_DIR}/src/lib/eina/
-    ${PROJECT_SOURCE_DIR}/src/lib/efl/
-)
+set(eina_TESTS eina_suite)
 
-add_definitions("-DTESTS_BUILD_DIR=\"1\"")
-add_definitions("-DPACKAGE_BUILD_DIR=\"1\"")
+set(eina_suite_LIBRARIES m)
 
-list(APPEND eina_test_source
-    eina_suite.c
-    eina_suite.h
-    eina_test_abi.c
-    eina_test_accessor.c
-    eina_test_array.c
-    eina_test_barrier.c
-    eina_test_benchmark.c
-    eina_test_bezier.c
-    eina_test_binbuf.c
-    eina_test_binshare.c
-    eina_test_clist.c
-    eina_test_convert.c
-    eina_test_counter.c
-    eina_test_cow.c
-    eina_test_crc.c
-    eina_test_error.c
-    eina_test_file.c
-    eina_test_fp.c
-    eina_test_freeq.c
-    eina_test_hash.c
-    eina_test_inarray.c
-    eina_test_inlist.c
-    eina_test_iterator.c
-    eina_test_lalloc.c
-    eina_test_list.c
-    eina_test_lock.c
-    eina_test_log.c
-    eina_test_magic.c
-    eina_test_main.c
-    eina_test_matrix.c
-    eina_test_matrixsparse.c
-    eina_test_mempool.c
-    eina_test_module.c
-    eina_test_module_dummy.c
-    eina_test_quad.c
-    eina_test_quadtree.c
-    eina_test_quaternion.c
-    eina_test_rbtree.c
-    eina_test_rectangle.c
-    eina_test_safepointer.c
-    eina_test_sched.c
-    eina_test_simple_xml_parser.c
-    eina_test_slice.c
-    eina_test_slstr.c
-    eina_test_str.c
-    eina_test_strbuf.c
-    eina_test_stringshare.c
-    eina_test_tiler.c
-    eina_test_tmpstr.c
-    eina_test_trash.c
-    eina_test_ustr.c
-    eina_test_ustringshare.c
-    eina_test_util.c
-    eina_test_value.c
-    eina_test_vector.c
-    eina_test_xattr.c
-)
+set(eina_suite_SOURCES
+  eina_suite.c
+  eina_suite.h
+  eina_suite.x
+  eina_test_abi.c
+  eina_test_accessor.c
+  eina_test_array.c
+  eina_test_barrier.c
+  eina_test_benchmark.c
+  eina_test_bezier.c
+  eina_test_binbuf.c
+  eina_test_binshare.c
+  eina_test_clist.c
+  eina_test_convert.c
+  eina_test_counter.c
+  eina_test_cow.c
+  eina_test_crc.c
+  eina_test_error.c
+  eina_test_file.c
+  eina_test_fp.c
+  eina_test_freeq.c
+  eina_test_hash.c
+  eina_test_inarray.c
+  eina_test_inlist.c
+  eina_test_iterator.c
+  eina_test_lalloc.c
+  eina_test_list.c
+  eina_test_lock.c
+  eina_test_log.c
+  eina_test_magic.c
+  eina_test_main.c
+  eina_test_matrix.c
+  eina_test_matrixsparse.c
+  eina_test_mempool.c
+  eina_test_module.c
+  eina_test_module_dummy.c
+  eina_test_quad.c
+  eina_test_quadtree.c
+  eina_test_quaternion.c
+  eina_test_rbtree.c
+  eina_test_rectangle.c
+  eina_test_safepointer.c
+  eina_test_sched.c
+  eina_test_simple_xml_parser.c
+  eina_test_slice.c
+  eina_test_slstr.c
+  eina_test_str.c
+  eina_test_strbuf.c
+  eina_test_tiler.c
+  eina_test_tmpstr.c
+  eina_test_trash.c
+  eina_test_ustr.c
+  eina_test_ustringshare.c
+  eina_test_value.c
+  eina_test_vector.c
+  eina_test_xattr.c
+  )
 
-add_executable(eina_suite "${eina_test_source}")
\ No newline at end of file
+set(eina_suite_DEPENDS
+  eina_test_stringshare.c
+  eina_test_util.c
+  )