From: Gustavo Sverzut Barbieri Date: Tue, 24 Jan 2017 01:55:33 +0000 (-0200) Subject: cmake: major rework of check and pkg-config dependencies. X-Git-Tag: upstream/1.20.0~2310 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa92926469881cdff7eda4627747fc964c2fa1a4;p=platform%2Fupstream%2Fefl.git cmake: major rework of check and pkg-config dependencies. make FUNC_CHECK(), TYPE_CHECK() and HEADER_CHECK() more general and they can be set to a scope, like "eina", then all symbols are prefixed with that. The scope is created with CHECK_INIT(), and EFL_HEADER_CHECKS_FINALIZE() will finish that. This makes it possible for cmake/config/eina.cmake + cmake/post/eina.cmake to add stuff to the generated file, better than hand edit the template. CHECK_APPEND_DEFINE(name val) is now the base to add symbols to the generated file in the current scope. Then convert cmake/config/eina.cmake to use that and match the autotools values (were a bit off). This exposed enabling valgrind was broken due incorrect pkg-config usage with cmake (it's not obvious), it was using just the libraries, while LDFLAGS are needed to get -L/usr/lib/valgrind. Then also convert to CFLAGS provided by pkg-config and make that automatic for PKG_CONFIG_REQUIRES and PKG_CONFIG_REQUIRES_PRIVATE. Also, eina-mempool modules use valgrind and must use that now that's propagating correctly. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 09479ba..a1d5dba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,6 @@ include(EflMacros) EFL_PROJECT(1.19.99) -if (NOT EFL_BUILD_ID) - set(EFL_BUILD_ID 120) -endif() - if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(FATAL_ERROR "In-source builds not allowed. Use: mkdir -p build && cmake -H. -Bbuild") endif() @@ -41,11 +37,14 @@ EFL_LIB(eo) EFL_OPTIONS_SUMMARY() -configure_file( - ${PROJECT_SOURCE_DIR}/src/lib/efl/config.h.cmake - ${PROJECT_BINARY_DIR}/src/lib/efl/config.h) +# TODO: when autotools is gone, rename this file in repository +# and remove this copy (using generate to skip @-subst) +file(GENERATE + OUTPUT ${PROJECT_BINARY_DIR}/src/lib/efl/config.h + INPUT ${PROJECT_SOURCE_DIR}/src/lib/efl/config.h.cmake) +EFL_HEADER_CHECKS_FINALIZE(${PROJECT_BINARY_DIR}/src/lib/efl/config_gen.h) + configure_file( ${PROJECT_SOURCE_DIR}/src/lib/efl/Efl_Config.h.cmake ${PROJECT_BINARY_DIR}/src/lib/efl/Efl_Config.h) -EFL_HEADER_CHECKS_FINALIZE(${PROJECT_BINARY_DIR}/src/lib/efl/config_headers.h) EFL_FINALIZE() diff --git a/cmake/config/common.cmake b/cmake/config/common.cmake index 11e45b0..b544ec5 100644 --- a/cmake/config/common.cmake +++ b/cmake/config/common.cmake @@ -18,12 +18,19 @@ endif() #define all our header / function checks include(./CommonHeaderChecks) +CHECK_APPEND_DEFINE(EFL_BETA_API_SUPPORT 1) +if(CMAKE_THREAD_LIBS_INIT) + set(EFL_HAVE_THREADS 1) +endif() +CHECK_APPEND_DEFINE(EFL_HAVE_THREADS "${EFL_HAVE_THREADS}") -#this is needed to build efl -set(EFL_BETA_API_SUPPORT 1) +CHECK_APPEND_DEFINE(MODULE_ARCH "\"v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}\"") +CHECK_APPEND_DEFINE(SHARED_LIB_SUFFIX "\"${CMAKE_SHARED_LIBRARY_SUFFIX}\"") +CHECK_APPEND_DEFINE(EXEEXT "\"${CMAKE_EXECUTABLE_SUFFIX}\"") -#if there are thread init support from cmake then efl has threads +# TODO: change code and remove: +CHECK_APPEND_DEFINE(VMAJ ${PROJECT_VERSION_MAJOR}) +CHECK_APPEND_DEFINE(VMIN ${PROJECT_VERSION_MINOR}) +CHECK_APPEND_DEFINE(VMIC ${PROJECT_VERSION_PATCH}) +CHECK_APPEND_DEFINE(VREV ${PROJECT_VERSION_TWEAK}) -if (CMAKE_THREAD_LIBS_INIT) - set(EFL_HAVE_THREADS 1) -endif() diff --git a/cmake/config/eina.cmake b/cmake/config/eina.cmake index b7da9ae..4091361 100644 --- a/cmake/config/eina.cmake +++ b/cmake/config/eina.cmake @@ -1,61 +1,88 @@ -SET_GLOBAL(EINA_SAFETY_CHECKS 1) -SET_GLOBAL(EINA_DEBUG_THREADS OFF) -SET_GLOBAL(ENABLE_VALGRIND OFF) +pkg_check_modules(VALGRIND valgrind) + +# set default option values based on BUILD_PROFILE +set(EINA_DEBUG_THREADS OFF) +set(ENABLE_VALGRIND OFF) if("${BUILD_PROFILE}" STREQUAL "dev") - SET_GLOBAL(EINA_STRINGSHARE_USAGE ON) - SET_GLOBAL(CHECK_VALGRIND ON) + set(ENABLE_VALGRIND ${VALGRIND_FOUND}) elseif("${BUILD_PROFILE}" STREQUAL "debug") - SET_GLOBAL(EINA_DEBUG_MALLOC ON) - SET_GLOBAL(EINA_COW_MAGIC_ON ON) - SET_GLOBAL(EINA_DEFAULT_MEMPOOL ON) - SET_GLOBAL(EINA_DEBUG_MALLOC ON) - SET_GLOBAL(EINA_DEBUG_THREADS ON) - SET_GLOBAL(ENABLE_VALGRIND ON) + set(EINA_DEBUG_THREADS ON) + set(ENABLE_VALGRIND ${VALGRIND_FOUND}) elseif("${BUILD_PROFILE}" STREQUAL "release") - SET_GLOBAL(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(ENABLE_VALGRIND "valgrind support" ${ENABLE_VALGRIND}) -SET_GLOBAL(EINA_MODULE_TYPE_MP_CHAINED_POOL_DEFAULT "STATIC") -SET_GLOBAL(EINA_MODULE_TYPE_MP_ONE_BIG_DEFAULT "STATIC") -SET_GLOBAL(EINA_MODULE_TYPE_MP_PASS_THROUGH_DEFAULT "STATIC") +set(EINA_MODULE_TYPE_MP_CHAINED_POOL_DEFAULT "STATIC") +set(EINA_MODULE_TYPE_MP_ONE_BIG_DEFAULT "STATIC") +set(EINA_MODULE_TYPE_MP_PASS_THROUGH_DEFAULT "STATIC") + +# no CHECK_INIT() yet, all CHECK_APPEND_DEFINE(), FUNC_CHECK(), +# HEADER_CHECK() and TYPE_CHECK() goes to src/lib/efl/config_gen.h + +if(ENABLE_VALGRIND) + if(NOT VALGRIND_FOUND) + message(FATAL_ERROR "Valgrind was required but not found!") + endif() + CHECK_APPEND_DEFINE(NVALGRIND "") +else() + CHECK_APPEND_DEFINE(NVALGRIND 1) +endif() + + +# we want the following checks inside src/lib/eina/eina_config.h to be +# generated from cmake/post/eina.cmake. +# +# By default all symbols are prefixed with EINA_ +CHECK_INIT(eina) + +if("${BUILD_PROFILE}" STREQUAL "dev") +elseif("${BUILD_PROFILE}" STREQUAL "debug") + set(EINA_STRINGSHARE_USAGE ON) + set(EINA_DEBUG_MALLOC ON) + set(EINA_COW_MAGIC_ON ON) + set(EINA_DEFAULT_MEMPOOL ON) + set(EINA_DEBUG_MALLOC ON) +elseif("${BUILD_PROFILE}" STREQUAL "release") + set(EINA_LOG_LEVEL_MAXIMUM 3) +endif() + +CHECK_APPEND_DEFINE(EINA_MAGIC_DEBUG ${EINA_MAGIC_DEBUG}) +CHECK_APPEND_DEFINE(EINA_SAFETY_CHECKS 1) +CHECK_APPEND_DEFINE(EINA_DEBUG_THREADS "${EINA_DEBUG_THREADS}") +CHECK_APPEND_DEFINE(EINA_STRINGSHARE_USAGE "${EINA_STRINGSHARE_USAGE}") +CHECK_APPEND_DEFINE(EINA_DEBUG_MALLOC "${EINA_DEBUG_MALLOC}") +CHECK_APPEND_DEFINE(EINA_COW_MAGIC_ON "${EINA_COW_MAGIC_ON}") +CHECK_APPEND_DEFINE(EINA_DEFAULT_MEMPOOL "${EINA_DEFAULT_MEMPOOL}") +CHECK_APPEND_DEFINE(EINA_DEBUG_MALLOC "${EINA_DEBUG_MALLOC}") +CHECK_APPEND_DEFINE(EINA_LOG_LEVEL_MAXIMUM "${EINA_LOG_LEVEL_MAXIMUM}") +CHECK_APPEND_DEFINE(EINA_HAVE_THREADS "${EFL_HAVE_THREADS}") #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) +FUNC_CHECK(pthread_barrier_init NAME EINA_HAVE_PTHREAD_BARRIER INCLUDE_FILES pthread.h FLAGS ${CMAKE_THREAD_LIBS_INIT} DEFINITIONS "-D_GNU_SOURCE=1") +FUNC_CHECK(pthread_attr_setaffinity_np NAME EINA_HAVE_PTHREAD_AFFINITY INCLUDE_FILES pthread.h FLAGS ${CMAKE_THREAD_LIBS_INIT} DEFINITIONS "-D_GNU_SOURCE=1") +FUNC_CHECK(pthread_setname_np NAME EINA_HAVE_PTHREAD_SETNAME INCLUDE_FILES pthread.h FLAGS ${CMAKE_THREAD_LIBS_INIT} DEFINITIONS "-D_GNU_SOURCE=1") +FUNC_CHECK(pthread_spin_init NAME EINA_HAVE_POSIX_SPINLOCK INCLUDE_FILES pthread.h FLAGS ${CMAKE_THREAD_LIBS_INIT} DEFINITIONS "-D_GNU_SOURCE=1") #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) +HEADER_CHECK(alloca.h) +HEADER_CHECK(byteswap.h) +HEADER_CHECK(fnmatch.h) #only enable log when fnmatch is there -if (EINA_HAVE_FNMATCH_H) - SET_GLOBAL(EINA_ENABLE_LOG 1) -endif (EINA_HAVE_FNMATCH_H) -CHECK_INCLUDE_FILE(dirent.h EINA_HAVE_DIRENT_H) +CHECK_APPEND_DEFINE(EINA_ENABLE_LOG ${EINA_HAVE_FNMATCH_H}) +HEADER_CHECK(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) +TYPE_CHECK(wchar_t) +TYPE_CHECK(uintptr_t) +TYPE_CHECK(wchar_t) +# TODO: fix define name to not need a name! #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) - -if(ENABLE_VALGRIND) - pkg_check_modules(VG REQUIRED valgrind) - SET_GLOBAL(NVALGRIND OFF) -else() - SET_GLOBAL(NVALGRIND ON) -endif() +FUNC_CHECK(bswap_16 NAME EINA_HAVE_BSWAP16 INCLUDE_FILES byteswap.h) +FUNC_CHECK(bswap_32 NAME EINA_HAVE_BSWAP32 INCLUDE_FILES byteswap.h) +FUNC_CHECK(bswap_64 NAME EINA_HAVE_BSWAP64 INCLUDE_FILES byteswap.h) #Check if there is the alloca header diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake index e320fb5..2f91e8a 100644 --- a/cmake/helpers/EflMacros.cmake +++ b/cmake/helpers/EflMacros.cmake @@ -132,7 +132,66 @@ function(EFL_FINALIZE) add_custom_target(all-tests DEPENDS ${EFL_ALL_TESTS}) endfunction() -unset(HEADER_FILE_CONTENT CACHE) +set(VAR_HEADER_FILE_CONTENT HEADER_FILE_CONTENT CACHE INTERNAL "") +unset(${VAR_HEADER_FILE_CONTENT} CACHE) +unset(CHECK_SCOPE CACHE) +unset(CHECK_SCOPE_UPPERCASE CACHE) + +# CHECK_INIT(scope) +# +# Initialize the scope for the following FUNC_CHECK, TYPE_CHECK, +# HEADER_CHECK... calls. +function(CHECK_INIT scope) + set(CHECK_SCOPE scope CACHE INTERNAL "Scope of current *_CHECK functions") + if(scope) + string(TOUPPER ${scope} scope_uc) + SET_GLOBAL(CHECK_SCOPE_UPPERCASE ${scope_uc}) + set(_suffix "_${scope_uc}") + else() + set(_suffix "") + endif() + SET_GLOBAL(VAR_HEADER_FILE_CONTENT HEADER_FILE_CONTENT${_suffix}) + SET_GLOBAL(${VAR_HEADER_FILE_CONTENT} "") +endfunction() + +# CHECK_APPEND_DEFINE(name value) +# +# If value evaluates to true: +# #define ${name} ${value} +# otherwise: +# /* #undef ${name} */ +# +# NOTE: ${name} is not modified at all, if it must include +# CHECK_SCOPE_UPPERCASE or CHECK_SCOPE, do it yourself. +function(CHECK_APPEND_DEFINE name value) + SET_GLOBAL(${VAR_HEADER_FILE_CONTENT} "${${VAR_HEADER_FILE_CONTENT}}#ifdef ${name}\n#undef ${name}\n#endif\n") + if(value) + if(value STREQUAL ON OR value STREQUAL TRUE) + set(value 1) + endif() + SET_GLOBAL(${VAR_HEADER_FILE_CONTENT} "${${VAR_HEADER_FILE_CONTENT}}#define ${name} ${value}\n\n") + else() + SET_GLOBAL(${VAR_HEADER_FILE_CONTENT} "${${VAR_HEADER_FILE_CONTENT}}/* #undef ${name} */\n\n") + endif() +endfunction() + +# CHECK_NAME_DEFAULT(name variable) +# +# Create the default name based on ${name} +# and stores in ${variable}. +# +# This will automatically prepend ${CHECK_SCOPE_UPPERCASE} if it's +# defined, will translate everything to uppercase and fix it to be a +# valid C-symbol. +function(CHECK_NAME_DEFAULT name var) + string(TOUPPER ${name} v) + string(REGEX REPLACE "[^a-zA-Z0-9]" "_" v "${v}") + string(REGEX REPLACE "_{2,}" "_" v "${v}") + if(CHECK_SCOPE_UPPERCASE) + set(v "${CHECK_SCOPE_UPPERCASE}_${v}") + endif() + set(${var} ${v} PARENT_SCOPE) +endfunction() # HEADER_CHECK(header [NAME variable] [INCLUDE_FILES extra1.h .. extraN.h]) # @@ -145,9 +204,7 @@ unset(HEADER_FILE_CONTENT CACHE) # # To include extra files, then use INCLUDE_FILES keyword. function(HEADER_CHECK header) - string(TOUPPER HAVE_${header} var) - string(REGEX REPLACE "[^a-zA-Z0-9]" "_" var "${var}") - string(REGEX REPLACE "_{2,}" "_" var "${var}") + CHECK_NAME_DEFAULT(HAVE_${header} var) cmake_parse_arguments(PARAMS "" "NAME" "INCLUDE_FILES" ${ARGN}) @@ -158,12 +215,7 @@ function(HEADER_CHECK header) set(CMAKE_EXTRA_INCLUDE_FILES "${PARAMS_INCLUDE_FILES}") CHECK_INCLUDE_FILE(${header} ${var}) - - if(${${var}}) - SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#define ${var} 1\n") - else() - SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#undef ${var}\n") - endif() + CHECK_APPEND_DEFINE(${var} "${${var}}") endfunction() # FUNC_CHECK(func [NAME variable] @@ -184,8 +236,7 @@ endfunction() # # To use C++ compiler, use CXX keyword function(FUNC_CHECK func) - string(TOUPPER HAVE_${func} var) - string(REGEX REPLACE "_{2,}" "_" var "${var}") + CHECK_NAME_DEFAULT(HAVE_${func} var) cmake_parse_arguments(PARAMS "CXX" "NAME" "INCLUDE_FILES;LIBRARIES;DEFINITIONS;FLAGS" ${ARGN}) @@ -193,20 +244,20 @@ function(FUNC_CHECK func) set(CMAKE_REQUIRED_DEFINITIONS "${PARAMS_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${PARAMS_FLAGS}") + if(PARAMS_NAME) + set(var ${PARAMS_NAME}) + endif() + if(PARAMS_CXX) check_cxx_symbol_exists(${func} "${PARAMS_INCLUDE_FILES}" ${var}) else() check_symbol_exists(${func} "${PARAMS_INCLUDE_FILES}" ${var}) endif() - if(${${var}} ) - SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#define ${var} 1\n") - else() - SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#undef ${var}\n") - endif() + CHECK_APPEND_DEFINE(${var} "${${var}}") endfunction() -# TYPE_CHECK(type [NAME variable] +# TYPE_CHECK(type [NAME variable] [SIZEOF variable] # [INCLUDE_FILES file1.h ... fileN.h] # [LIBRARIES lib1 ... libN] # [DEFINITIONS -DA=1 .. -DN=123] @@ -224,16 +275,24 @@ endfunction() # # To use C++ compiler, use CXX keyword function(TYPE_CHECK type) - string(TOUPPER HAVE_${type} var) - string(REGEX REPLACE "_{2,}" "_" var "${var}") + CHECK_NAME_DEFAULT(HAVE_${type} var) + CHECK_NAME_DEFAULT(SIZEOF_${type} sizeof) - cmake_parse_arguments(PARAMS "CXX" "NAME" "INCLUDE_FILES;LIBRARIES;DEFINITIONS;FLAGS" ${ARGN}) + cmake_parse_arguments(PARAMS "CXX" "NAME;SIZEOF" "INCLUDE_FILES;LIBRARIES;DEFINITIONS;FLAGS" ${ARGN}) set(CMAKE_REQUIRED_LIBRARIES "${PARAMS_LIBRARIES}") set(CMAKE_REQUIRED_DEFINITIONS "${PARAMS_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${PARAMS_FLAGS}") set(CMAKE_EXTRA_INCLUDE_FILES "${PARAMS_INCLUDE_FILES}") + if(PARAMS_NAME) + set(var ${PARAMS_NAME}) + endif() + + if(PARAMS_SIZEOF) + set(sizeof ${PARAMS_SIZEOF}) + endif() + if(PARAMS_CXX) set(lang CXX) else() @@ -241,12 +300,8 @@ function(TYPE_CHECK type) endif() CHECK_TYPE_SIZE(${type} ${var} LANGUAGE ${lang}) - - if(HAVE_${var}) - SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#define ${var} 1\n") - else() - SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#undef ${var}\n") - endif() + CHECK_APPEND_DEFINE(${var} "${HAVE_${var}}") + CHECK_APPEND_DEFINE(${sizeof} "${${var}}") endfunction() # EFL_HEADER_CHECKS_FINALIZE(file) @@ -254,7 +309,11 @@ endfunction() # Write the configuration gathered with HEADER_CHECK(), TYPE_CHECK() # and FUNC_CHECK() to the given file. function(EFL_HEADER_CHECKS_FINALIZE file) - file(WRITE ${file}.new ${HEADER_FILE_CONTENT}) + get_filename_component(filename ${file} NAME) + string(TOUPPER _${filename}_ file_sym) + string(REGEX REPLACE "[^a-zA-Z0-9]" "_" file_sym "${file_sym}") + + file(WRITE ${file}.new "#ifndef ${file_sym}\n#define ${file_sym} 1\n\n${${VAR_HEADER_FILE_CONTENT}}\n#endif /* ${file_sym} */\n") if (NOT EXISTS ${file}) file(RENAME ${file}.new ${file}) message(STATUS "${file} was generated.") @@ -269,7 +328,10 @@ function(EFL_HEADER_CHECKS_FINALIZE file) message(STATUS "${file} was updated.") endif() endif() - unset(HEADER_FILE_CONTENT CACHE) # allow to reuse with an empty contents + unset(${VAR_HEADER_FILE_CONTENT} CACHE) # allow to reuse with an empty contents + unset(CHECK_SCOPE CACHE) + unset(CHECK_SCOPE_UPPERCASE CACHE) + set(VAR_HEADER_FILE_CONTENT HEADER_FILE_CONTENT CACHE INTERNAL "") endfunction() # EFL_FILES_TO_ABSOLUTE(Var Source_Dir Binary_Dir [file1 ... fileN]) @@ -322,6 +384,12 @@ function(EFL_PKG_CONFIG_EVAL_TO _var _name) if(NOT _missing) SET_GLOBAL(${_var} "${_found}") SET_GLOBAL(${_var}_MISSING "${_missing_optional}") + + if(_found) + pkg_check_modules(PKG_CONFIG_${_var} ${_found}) + SET_GLOBAL(${_var}_CFLAGS "${PKG_CONFIG_${_var}_CFLAGS}") + SET_GLOBAL(${_var}_LDFLAGS "${PKG_CONFIG_${_var}_LDFLAGS}") + endif() else() message(FATAL_ERROR "${_name} missing required pkg-config modules: ${_missing}") endif() @@ -669,6 +737,13 @@ function(EFL_LIB _target) EFL_PKG_CONFIG_EVAL(${_target} "${PKG_CONFIG_REQUIRES_PRIVATE}" "${PKG_CONFIG_REQUIRES}") + set(_link_flags ${${_target}_PKG_CONFIG_REQUIRES_PRIVATE_LDFLAGS} ${${_target}_PKG_CONFIG_REQUIRES_LDFLAGS}) + set(__compile_flags ${${_target}_PKG_CONFIG_REQUIRES_PRIVATE_CFLAGS} ${${_target}_PKG_CONFIG_REQUIRES_CFLAGS} -DPACKAGE_DATA_DIR=\\"${CMAKE_INSTALL_FULL_DATADIR}/${_target}/\\") + set(_compile_flags) + # CMake uses string for COMPILE_FLAGS but list for LINK_FLAGS... :-/ + foreach(_c ${__compile_flags}) + set(_compile_flags "${_compile_flags} ${_c}") + endforeach() add_library(${_target} ${LIBRARY_TYPE} ${_sources} ${_headers}) set_target_properties(${_target} PROPERTIES @@ -677,7 +752,8 @@ function(EFL_LIB _target) OBJECT_DEPENDS "${_obj_deps}" EFL_EO_PRIVATE "${_eo_files}" EFL_EO_PUBLIC "${_public_eo_files}" - COMPILE_FLAGS -DPACKAGE_DATA_DIR=\\"${CMAKE_INSTALL_FULL_DATADIR}/${_target}/\\") + LINK_FLAGS "${_link_flags}" + COMPILE_FLAGS "${_compile_flags}") if(DEPENDENCIES) add_dependencies(${_target} ${DEPENDENCIES}) @@ -793,6 +869,8 @@ function(EFL_BIN _binname) set(DEFINITIONS) set(INSTALL ON) set(INSTALL_DIR bin) + set(PKG_CONFIG_REQUIRES) + set(PKG_CONFIG_REQUIRES_PRIVATE) if(_binname STREQUAL ${EFL_LIB_CURRENT}) set(_binsrcdir "${EFL_BIN_SOURCE_DIR}") @@ -813,10 +891,15 @@ function(EFL_BIN _binname) if(PUBLIC_HEADERS) message(WARNING "${_binsrcdir}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.") endif() + if(PKG_CONFIG_REQUIRES) + message(WARNING "${_binsrcdir}/CMakeLists.txt should not define PKG_CONFIG_REQUIRES. Use PKG_CONFIG_REQUIRES_PRIVATE instead") + endif() EFL_FILES_TO_ABSOLUTE(_sources ${_binsrcdir} ${_binbindir} ${SOURCES}) EFL_FILES_TO_ABSOLUTE(_obj_deps ${_binsrcdir} ${_binbindir} ${OBJECT_DEPENDS}) + EFL_PKG_CONFIG_EVAL(${_bintarget} "${PKG_CONFIG_REQUIRES_PRIVATE}" "") + add_executable(${_bintarget} ${_sources}) if(_obj_deps) @@ -848,6 +931,16 @@ function(EFL_BIN _binname) set_target_properties(${_bintarget} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME}) endif() + # CMake uses string for COMPILE_FLAGS but list for LINK_FLAGS... :-/ + set(_compile_flags) + foreach(_c ${${_bintarget}_PKG_CONFIG_REQUIRES_PRIVATE_CFLAGS}) + set(_compile_flags "${_compile_flags} ${_c}") + endforeach() + + set_target_properties(${_bintarget} PROPERTIES + LINK_FLAGS "${${_bintarget}_PKG_CONFIG_REQUIRES_PRIVATE_LDFLAGS}" + COMPILE_FLAGS "${_compile_flags}") + if(INSTALL_DIR) install(TARGETS ${_bintarget} RUNTIME DESTINATION ${INSTALL_DIR}) endif() @@ -889,6 +982,8 @@ function(EFL_TEST _testname) endif() set(LIBRARIES) set(DEFINITIONS) + set(PKG_CONFIG_REQUIRES) + set(PKG_CONFIG_REQUIRES_PRIVATE) if(_testname STREQUAL ${EFL_LIB_CURRENT}) set(_testsrcdir "${EFL_TESTS_SOURCE_DIR}") @@ -910,10 +1005,15 @@ function(EFL_TEST _testname) if(PUBLIC_HEADERS) message(WARNING "${_testsrcdir}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.") endif() + if(PKG_CONFIG_REQUIRES) + message(WARNING "${_testsrcdir}/CMakeLists.txt should not define PKG_CONFIG_REQUIRES. Use PKG_CONFIG_REQUIRES_PRIVATE instead") + endif() EFL_FILES_TO_ABSOLUTE(_sources ${_testsrcdir} ${_testbindir} ${SOURCES}) EFL_FILES_TO_ABSOLUTE(_obj_deps ${_testsrcdir} ${_testbindir} ${OBJECT_DEPENDS}) + EFL_PKG_CONFIG_EVAL(${_testtarget} "${PKG_CONFIG_REQUIRES_PRIVATE}" "") + add_executable(${_testtarget} EXCLUDE_FROM_ALL ${_sources}) if(_obj_deps) @@ -949,7 +1049,15 @@ function(EFL_TEST _testname) set_target_properties(${_testtarget} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME}) endif() + # CMake uses string for COMPILE_FLAGS but list for LINK_FLAGS... :-/ + set(_compile_flags) + foreach(_c ${${_testtarget}_PKG_CONFIG_REQUIRES_PRIVATE_CFLAGS}) + set(_compile_flags "${_compile_flags} ${_c}") + endforeach() + set_target_properties(${_testtarget} PROPERTIES + LINK_FLAGS "${${_testtarget}_PKG_CONFIG_REQUIRES_PRIVATE_LDFLAGS}" + COMPILE_FLAGS "${_compile_flags}" LIBRARY_OUTPUT_DIRECTORY "${_testbindir}" RUNTIME_OUTPUT_DIRECTORY "${_testbindir}") @@ -978,6 +1086,9 @@ endfunction() # - INSTALL_DIR: defaults to # lib/${EFL_LIB_CURRENT}/modules/${EFL_MODULE_SCOPE}/${Name}/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}/. # If empty, won't install. +# - PKG_CONFIG_REQUIRES_PRIVATE: results in +# ${Name}_PKG_CONFIG_REQUIRES_PRIVATE. Elements after 'OPTIONAL' +# keyword are optional. # # NOTE: since the file will be included it shouldn't mess with global variables! function(EFL_MODULE _modname) @@ -1011,6 +1122,8 @@ function(EFL_MODULE _modname) set(DEFINITIONS) set(MODULE_TYPE "${${_modoptionname}}") set(INSTALL_DIR ${_modoutdir}) + set(PKG_CONFIG_REQUIRES) + set(PKG_CONFIG_REQUIRES_PRIVATE) _EFL_INCLUDE_OR_DETECT("Module ${_modtarget}" ${_modsrcdir}) @@ -1021,6 +1134,9 @@ function(EFL_MODULE _modname) if(PUBLIC_HEADERS) message(WARNING "${_modsrcdir}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.") endif() + if(PKG_CONFIG_REQUIRES) + message(WARNING "${_modsrcdir}/CMakeLists.txt should not define PKG_CONFIG_REQUIRES. Use PKG_CONFIG_REQUIRES_PRIVATE instead") + endif() if("${MODULE_TYPE}" STREQUAL "OFF") return() @@ -1033,6 +1149,8 @@ function(EFL_MODULE _modname) EFL_FILES_TO_ABSOLUTE(_sources ${_modsrcdir} ${_modbindir} ${SOURCES}) EFL_FILES_TO_ABSOLUTE(_obj_deps ${_modsrcdir} ${_modbindir} ${OBJECT_DEPENDS}) + EFL_PKG_CONFIG_EVAL(${_modtarget} "${PKG_CONFIG_REQUIRES_PRIVATE}" "") + add_library(${_modtarget} ${_modtype} ${_sources}) set_target_properties(${_modtarget} PROPERTIES OBJECT_DEPENDS "${_obj_deps}" @@ -1049,7 +1167,15 @@ function(EFL_MODULE _modname) target_compile_definitions(${_modtarget} PRIVATE ${DEFINITIONS}) + # CMake uses string for COMPILE_FLAGS but list for LINK_FLAGS... :-/ + set(_compile_flags) + foreach(_c ${${_modtarget}_PKG_CONFIG_REQUIRES_PRIVATE_CFLAGS}) + set(_compile_flags "${_compile_flags} ${_c}") + endforeach() + set_target_properties(${_modtarget} PROPERTIES + LINK_FLAGS "${${_modtarget}_PKG_CONFIG_REQUIRES_PRIVATE_LDFLAGS}" + COMPILE_FLAGS "${_compile_flags}" LIBRARY_OUTPUT_DIRECTORY "${_modoutdir}" ARCHIVE_OUTPUT_DIRECTORY "${_modoutdir}" RUNTIME_OUTPUT_DIRECTORY "${_modoutdir}") diff --git a/cmake/post/eina.cmake b/cmake/post/eina.cmake index 37be34d..72088d7 100644 --- a/cmake/post/eina.cmake +++ b/cmake/post/eina.cmake @@ -1,21 +1,27 @@ # TODO: change code to avoid these -if(EINA_MODULE_TYPE_MP_CHAINED STREQUAL "STATIC") - SET_GLOBAL(EINA_STATIC_BUILD_CHAINED_POOL 1) +if(EINA_MODULE_TYPE_MP_CHAINED_POOL STREQUAL "STATIC") + CHECK_APPEND_DEFINE(EINA_STATIC_BUILD_CHAINED_POOL 1) else() - unset(EINA_STATIC_BUILD_CHAINED_POOL CACHE) + CHECK_APPEND_DEFINE(EINA_STATIC_BUILD_CHAINED_POOL "") endif() if(EINA_MODULE_TYPE_MP_ONE_BIG STREQUAL "STATIC") - SET_GLOBAL(EINA_STATIC_BUILD_ONE_BIG 1) + CHECK_APPEND_DEFINE(EINA_STATIC_BUILD_ONE_BIG 1) else() - unset(EINA_STATIC_BUILD_ONE_BIG CACHE) + CHECK_APPEND_DEFINE(EINA_STATIC_BUILD_ONE_BIG "") endif() if(EINA_MODULE_TYPE_MP_PASS_THROUGH STREQUAL "STATIC") - SET_GLOBAL(EINA_STATIC_BUILD_PASS_THROUGH 1) + CHECK_APPEND_DEFINE(EINA_STATIC_BUILD_PASS_THROUGH 1) else() - unset(EINA_STATIC_BUILD_PASS_THROUGH CACHE) + CHECK_APPEND_DEFINE(EINA_STATIC_BUILD_PASS_THROUGH "") endif() -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/eina/eina_config.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/src/lib/eina/eina_config.h) +# generate the file and close the scope started with CHECK_INIT(eina): +EFL_HEADER_CHECKS_FINALIZE(${CMAKE_CURRENT_BINARY_DIR}/src/lib/eina/eina_config_gen.h) + +# TODO: when autotools is gone, rename this file in repository +# and remove this copy (using generate to skip @-subst) +file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/lib/eina/eina_config.h + INPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/eina/eina_config.h.cmake +) diff --git a/src/lib/efl/Efl_Config.h.cmake b/src/lib/efl/Efl_Config.h.cmake index e1c199c..a99d153 100644 --- a/src/lib/efl/Efl_Config.h.cmake +++ b/src/lib/efl/Efl_Config.h.cmake @@ -15,7 +15,7 @@ and require an explicit request to get it. */ #endif -#define EFL_VERSION_MAJOR @EFL_VERSION_MAJOR@ -#define EFL_VERSION_MINOR @EFL_VERSION_MINOR@ -#define EFL_BUILD_ID "@EFL_BUILD_ID@" +#define EFL_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define EFL_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define EFL_BUILD_ID "@PROJECT_VERSION_TWEAK@" #endif diff --git a/src/lib/efl/config.h.cmake b/src/lib/efl/config.h.cmake index 47ceb53..35ab3c3 100644 --- a/src/lib/efl/config.h.cmake +++ b/src/lib/efl/config.h.cmake @@ -3,22 +3,7 @@ #define _GNU_SOURCE -#include "config_headers.h" - -#define VMAJ @PROJECT_VERSION_MAJOR@ -#define VMIN @PROJECT_VERSION_MINOR@ -#define VMIC @PROJECT_VERSION_PATCH@ -#define VREV @PROJECT_VERSION_TWEAK@ - -#cmakedefine NVALGRIND 1 - -#cmakedefine EINA_STATIC_BUILD_CHAINED_POOL 1 -#cmakedefine EINA_STATIC_BUILD_ONE_BIG 1 -#cmakedefine EINA_STATIC_BUILD_PASS_THROUGH 1 - -#define MODULE_ARCH "v-@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@" -#define SHARED_LIB_SUFFIX "@CMAKE_SHARED_LIBRARY_SUFFIX@" -#define EXEEXT "@CMAKE_EXECUTABLE_SUFFIX@" +#include "config_gen.h" #if defined (HAVE_LISTXATTR) && defined (HAVE_SETXATTR) && defined (HAVE_GETXATTR) #define HAVE_XATTR @@ -27,11 +12,4 @@ //for now statically define that to one #define STRERROR_R_CHAR_P 1 -#cmakedefine EFL_ALWAYS_INLINE @EFL_ALWAYS_INLINE@ -#cmakedefine EFL_HAVE_OSX_SPINLOCK 1 -#cmakedefine EFL_HAVE_POSIX_THREADS_SPINLOCK 1 -#cmakedefine EFL_HAVE_THREADS 1 - -#cmakedefine HAVE_EO_ID - #endif diff --git a/src/lib/eina/CMakeLists.txt b/src/lib/eina/CMakeLists.txt index 6c16016..dabbabf 100644 --- a/src/lib/eina/CMakeLists.txt +++ b/src/lib/eina/CMakeLists.txt @@ -13,8 +13,6 @@ set(LIBRARIES if(ENABLE_VALGRIND) list(APPEND PKG_CONFIG_REQUIRES_PRIVATE valgrind) - list(APPEND INCLUDE_DIRECTORIES ${VG_INCLUDE_DIRS}) - list(APPEND LIBRARIES ${VG_LIBRARIES}) endif() set(PUBLIC_HEADERS @@ -28,6 +26,7 @@ set(PUBLIC_HEADERS eina_binshare.h eina_clist.h eina_config.h + eina_config_gen.h eina_convert.h eina_counter.h eina_cow.h diff --git a/src/lib/eina/eina_config.h.cmake b/src/lib/eina/eina_config.h.cmake index a4aac7d..6db7c81 100644 --- a/src/lib/eina/eina_config.h.cmake +++ b/src/lib/eina/eina_config.h.cmake @@ -23,104 +23,7 @@ # include #endif -#ifdef EINA_MAGIC_DEBUG -# undef EINA_MAGIC_DEBUG -#endif -#cmakedefine EINA_MAGIC_DEBUG - -#ifndef EINA_DEFAULT_MEMPOOL -# undef EINA_DEFAULT_MEMPOOL -#endif -#cmakedefine EINA_DEFAULT_MEMPOOL - -#ifdef EINA_SAFETY_CHECKS -# undef EINA_SAFETY_CHECKS -#endif -#cmakedefine EINA_SAFETY_CHECKS - -#ifndef EINA_HAVE_THREADS -#define EINA_HAVE_THREADS -#endif - -#ifdef EINA_HAVE_PTHREAD_AFFINITY -# undef EINA_HAVE_PTHREAD_AFFINITY -#endif -#cmakedefine EINA_HAVE_PTHREAD_AFFINITY - -#ifdef EINA_HAVE_PTHREAD_BARRIER -# undef EINA_HAVE_PTHREAD_BARRIER -#endif -#cmakedefine EINA_HAVE_PTHREAD_BARRIER - -#ifdef EINA_HAVE_PTHREAD_SETNAME -# undef EINA_HAVE_PTHREAD_SETNAME -#endif -#cmakedefine EINA_HAVE_PTHREAD_SETNAME - -#ifdef EINA_HAVE_DEBUG_THREADS -# undef EINA_HAVE_DEBUG_THREADS -#endif -#cmakedefine EINA_HAVE_DEBUG_THREADS - -#ifdef EINA_SIZEOF_WCHAR_T -# undef EINA_SIZEOF_WCHAR_T -#endif -#cmakedefine EINA_SIZEOF_WCHAR_T @EINA_SIZEOF_WCHAR_T@ - -#ifdef EINA_SIZEOF_UINTPTR_T -# undef EINA_SIZEOF_UINTPTR_T -#endif -#cmakedefine EINA_SIZEOF_UINTPTR_T @EINA_SIZEOF_UINTPTR_T@ - -#ifdef EINA_CONFIGURE_HAVE_DIRENT_H -# undef EINA_CONFIGURE_HAVE_DIRENT_H -#endif -#cmakedefine EINA_HAVE_DIRENT_H - -#ifdef EINA_CONFIGURE_ENABLE_LOG -# undef EINA_CONFIGURE_ENABLE_LOG -#endif -#cmakedefine EINA_ENABLE_LOG - -#ifdef EINA_HAVE_ALLOCA_H -# undef EINA_HAVE_ALLOCA_H -#endif -#cmakedefine EINA_HAVE_ALLOCA_H - -#ifdef EINA_HAVE_BSWAP16 -# undef EINA_HAVE_BSWAP16 -#endif -#cmakedefine EINA_HAVE_BSWAP16 - -#ifdef EINA_HAVE_BSWAP32 -# undef EINA_HAVE_BSWAP32 -#endif -#cmakedefine EINA_HAVE_BSWAP32 - -#ifdef EINA_HAVE_BSWAP64 -# undef EINA_HAVE_BSWAP64 -#endif -#cmakedefine EINA_HAVE_BSWAP64 - -#ifdef EINA_HAVE_BYTESWAP_H -# undef EINA_HAVE_BYTESWAP_H -#endif -#cmakedefine EINA_HAVE_BYTESWAP_H - -#ifdef EINA_HAVE_POSIX_SPINLOCK -# undef EINA_HAVE_POSIX_SPINLOCK -#endif -#cmakedefine EINA_HAVE_POSIX_SPINLOCK - -#ifndef EINA_HAVE_OSX_SPINLOCK -# undef EINA_HAVE_OSX_SPINLOCK -#endif -@EINA_CONFIGURE_HAVE_OSX_SPINLOCK@ - -#ifndef EINA_HAVE_OSX_SEMAPHORE -# undef EINA_HAVE_OSX_SEMAPHORE -#endif -@EINA_CONFIGURE_HAVE_OSX_SEMAPHORE@ +#include "eina_config_gen.h" #include 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 0000000..fd564b7 --- /dev/null +++ b/src/modules/eina/mp/chained_pool/CMakeLists.txt @@ -0,0 +1,5 @@ +if(ENABLE_VALGRIND) + list(APPEND PKG_CONFIG_REQUIRES_PRIVATE valgrind) +endif() + +set(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 0000000..49e758f --- /dev/null +++ b/src/modules/eina/mp/one_big/CMakeLists.txt @@ -0,0 +1,5 @@ +if(ENABLE_VALGRIND) + list(APPEND PKG_CONFIG_REQUIRES_PRIVATE valgrind) +endif() + +set(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 0000000..0ab1349 --- /dev/null +++ b/src/modules/eina/mp/pass_through/CMakeLists.txt @@ -0,0 +1,5 @@ +if(ENABLE_VALGRIND) + list(APPEND PKG_CONFIG_REQUIRES_PRIVATE valgrind) +endif() + +set(SOURCES eina_pass_through.c)