summaryrefslogtreecommitdiff
path: root/cmake/helpers/EflMacros.cmake
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-25 19:16:06 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-25 19:29:20 -0200
commita2bc5ee1306184c8abab4c7eb62ddedb74687900 (patch)
treecbafd4788731d48060c49eaac8d6ba9cf59537f7 /cmake/helpers/EflMacros.cmake
parente4d0f78682b6227be68c3d00c42c4cc92c8822ef (diff)
cmake: improvements to eolian handling.
- fix doc and state SOURCES shouldn't get any EO_FILES, these should go to the specific PUBLIC_EO_FILES or EO_FILES. - generate eolian files in relative directories, required by efl/interfaces - .eot files fail if you give -o c:..., they need an explicit "-gh" followed by "-o i:..." - .legacy.h are generated automatically, but needs an extra pass (q66 was informed about it) - if EOLIAN_BIN=on, then use in-tree binary, depending on such target only if it's the case. This allow cross-compiling and also bypass regenerate all .eo files if eina/eolian changed (as requested by Raster), simply reconfigure with EOLIAN_BIN=path, which can be EOLIAN_BIN=bin/eolian_gen if you wish ;-) - use COMMENT keyword to change the eolian summary (output)
Diffstat (limited to 'cmake/helpers/EflMacros.cmake')
-rw-r--r--cmake/helpers/EflMacros.cmake55
1 files changed, 46 insertions, 9 deletions
diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake
index b41d96ef8f..e00e4d8df3 100644
--- a/cmake/helpers/EflMacros.cmake
+++ b/cmake/helpers/EflMacros.cmake
@@ -559,7 +559,6 @@ macro(_EFL_INCLUDE_OR_DETECT _name _srcdir)
559 ${_srcdir}/*.hh 559 ${_srcdir}/*.hh
560 ${_srcdir}/*.cxx 560 ${_srcdir}/*.cxx
561 ${_srcdir}/*.cpp 561 ${_srcdir}/*.cpp
562 ${_srcdir}/*.eo
563 ) 562 )
564 list(LENGTH _autodetect_files _autodetect_files_count) 563 list(LENGTH _autodetect_files _autodetect_files_count)
565 if(_autodetect_files_count GREATER 1) 564 if(_autodetect_files_count GREATER 1)
@@ -571,9 +570,15 @@ macro(_EFL_INCLUDE_OR_DETECT _name _srcdir)
571 ${_srcdir}/*.hh 570 ${_srcdir}/*.hh
572 ${_srcdir}/*.cxx 571 ${_srcdir}/*.cxx
573 ${_srcdir}/*.cpp 572 ${_srcdir}/*.cpp
573 )
574 file(GLOB EO_FILES RELATIVE ${_srcdir}
574 ${_srcdir}/*.eo 575 ${_srcdir}/*.eo
576 ${_srcdir}/*.eot
575 ) 577 )
576 message(STATUS "${_name} auto-detected as: ${SOURCES}") 578 message(STATUS "${_name} auto-detected as: ${SOURCES}")
579 if(EO_FILES)
580 message(STATUS "${_name} EO auto-detected as: ${EO_FILES}")
581 endif()
577 else() 582 else()
578 message(STATUS "${_name} contains no auto-detectable sources.") 583 message(STATUS "${_name} contains no auto-detectable sources.")
579 endif() 584 endif()
@@ -683,7 +688,8 @@ define_property(TARGET PROPERTY EFL_EO_PUBLIC
683# - INCLUDE_DIRECTORIES: results in target_include_directories 688# - INCLUDE_DIRECTORIES: results in target_include_directories
684# - SYSTEM_INCLUDE_DIRECTORIES: results in target_include_directories(SYSTEM) 689# - SYSTEM_INCLUDE_DIRECTORIES: results in target_include_directories(SYSTEM)
685# - OUTPUT_NAME 690# - OUTPUT_NAME
686# - SOURCES source files that are needed, eo files can also be added here to be build 691# - SOURCES source files that are needed. Eo files should go in
692# PUBLIC_EO_FILES or EO_FILES.
687# - PUBLIC_HEADERS 693# - PUBLIC_HEADERS
688# - VERSION (defaults to project version) 694# - VERSION (defaults to project version)
689# - SOVERSION (defaults to project major version) 695# - SOVERSION (defaults to project major version)
@@ -849,7 +855,7 @@ function(EFL_LIB _target)
849 SOVERSION ${SOVERSION}) 855 SOVERSION ${SOVERSION})
850 endif() 856 endif()
851 857
852 EFL_CREATE_EO_RULES(${_target} ${EFL_LIB_BINARY_DIR}) 858 EFL_CREATE_EO_RULES(${_target} ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR})
853 859
854 EFL_PKG_CONFIG_LIB_WRITE() 860 EFL_PKG_CONFIG_LIB_WRITE()
855 861
@@ -1289,7 +1295,7 @@ endmacro()
1289 1295
1290# Will use the source of the given target to create rules for creating 1296# Will use the source of the given target to create rules for creating
1291# the .eo.c and .eo.h files. The INCLUDE_DIRECTORIES of the target will be used 1297# the .eo.c and .eo.h files. The INCLUDE_DIRECTORIES of the target will be used
1292function(EFL_CREATE_EO_RULES target generation_dir) 1298function(EFL_CREATE_EO_RULES target source_dir generation_dir)
1293 get_target_property(eo_files_private ${target} EFL_EO_PRIVATE) 1299 get_target_property(eo_files_private ${target} EFL_EO_PRIVATE)
1294 get_target_property(eo_files_public ${target} EFL_EO_PUBLIC) 1300 get_target_property(eo_files_public ${target} EFL_EO_PUBLIC)
1295 if(NOT eo_files_private AND NOT eo_files_public) 1301 if(NOT eo_files_private AND NOT eo_files_public)
@@ -1300,18 +1306,34 @@ function(EFL_CREATE_EO_RULES target generation_dir)
1300 set(all_libraries ${target} ${link_libraries}) 1306 set(all_libraries ${target} ${link_libraries})
1301 set(include_cmd "") 1307 set(include_cmd "")
1302 foreach(link_target ${all_libraries}) 1308 foreach(link_target ${all_libraries})
1303 list(APPEND include_cmd -I${CMAKE_SOURCE_DIR}/src/lib/${link_target}) 1309 if(TARGET ${link_target})
1310 list(APPEND include_cmd -I${CMAKE_SOURCE_DIR}/src/lib/${link_target})
1311 endif()
1304 endforeach() 1312 endforeach()
1305 1313
1306 set(all_eo_gen_files "") 1314 set(all_eo_gen_files "")
1307 foreach(file ${eo_files_private} ${eo_files_public}) 1315 foreach(file ${eo_files_private} ${eo_files_public})
1308 get_filename_component(ext ${file} EXT) 1316 get_filename_component(ext ${file} EXT)
1309 get_filename_component(filename ${file} NAME) 1317 string(REGEX REPLACE "^${source_dir}/" "" filename "${file}")
1318 string(REGEX REPLACE "^${CMAKE_SOURCE_DIR}/" "" relfile "${file}")
1319
1320 # if sources are located in subdiretories
1321 get_filename_component(reldir "${filename}" DIRECTORY)
1322 if(reldir)
1323 file(MAKE_DIRECTORY "${generation_dir}/${reldir}")
1324 get_filename_component(absdir "${file}" DIRECTORY)
1325 set(rel_include_cmd -I${absdir})
1326 else()
1327 set(rel_include_cmd)
1328 endif()
1310 1329
1311 if(${ext} STREQUAL ".eo") 1330 if(${ext} STREQUAL ".eo")
1312 set(file_eo_gen_files ${generation_dir}/${filename}.c ${generation_dir}/${filename}.h) 1331 set(file_eo_gen_files ${generation_dir}/${filename}.c ${generation_dir}/${filename}.h) # TODO: ${generation_dir}/${filename}.legacy.h)
1332 set(out_cmd -o c:${generation_dir}/${filename}.c -o h:${generation_dir}/${filename}.h) # TODO: bug in eolian_gen -o l:${generation_dir}/${filename}.legacy.h)
1313 elseif(${ext} STREQUAL ".eot") 1333 elseif(${ext} STREQUAL ".eot")
1314 set(file_eo_gen_files ${generation_dir}/${filename}.h) 1334 set(file_eo_gen_files ${generation_dir}/${filename}.h)
1335 # TODO: looks like a bug in eolian_gen needs '-gh'
1336 set(out_cmd -gh -o h:${generation_dir}/${filename}.h)
1315 else() 1337 else()
1316 message(FATAL_ERROR "Unsupported eo file type: ${file}") 1338 message(FATAL_ERROR "Unsupported eo file type: ${file}")
1317 endif() 1339 endif()
@@ -1320,13 +1342,26 @@ function(EFL_CREATE_EO_RULES target generation_dir)
1320 if(file_eo_gen_files) 1342 if(file_eo_gen_files)
1321 if(EOLIAN_BIN STREQUAL ON) 1343 if(EOLIAN_BIN STREQUAL ON)
1322 set(EOLIAN_BIN ${CMAKE_BINARY_DIR}/bin/eolian_gen) 1344 set(EOLIAN_BIN ${CMAKE_BINARY_DIR}/bin/eolian_gen)
1345 set(IN_TREE_EOLIAN ON)
1323 endif() 1346 endif()
1324 add_custom_command( 1347 add_custom_command(
1325 OUTPUT ${file_eo_gen_files} 1348 OUTPUT ${file_eo_gen_files}
1326 COMMAND ${CMAKE_COMMAND} -E env "EFL_RUN_IN_TREE=1" ${EOLIAN_BIN} ${include_cmd} -o c:${generation_dir}/${filename}.c -o h:${generation_dir}/${filename}.h ${file} 1349 COMMAND ${EOLIAN_BIN} ${rel_include_cmd} ${include_cmd} ${EOLIAN_EXTRA_PARAMS} ${out_cmd} ${file}
1327 DEPENDS ${file} 1350 DEPENDS ${file}
1351 COMMENT "EOLIAN ${relfile}"
1328 ) 1352 )
1329 list(APPEND all_eo_gen_files ${file_eo_gen_files}) 1353 list(APPEND all_eo_gen_files ${file_eo_gen_files})
1354 # TODO: looks like a bug in eolian_gen doesn't generate -o l:...
1355 # TODO: then add an extra command
1356 if(${ext} STREQUAL ".eo")
1357 add_custom_command(
1358 OUTPUT ${generation_dir}/${filename}.legacy.h
1359 COMMAND ${EOLIAN_BIN} ${rel_include_cmd} ${include_cmd} ${EOLIAN_EXTRA_PARAMS} -gl -o l:${generation_dir}/${filename}.legacy.h ${file}
1360 DEPENDS ${file}
1361 COMMENT "EOLIAN LEGACY ${relfile}"
1362 )
1363 list(APPEND all_eo_gen_files ${generation_dir}/${filename}.legacy.h)
1364 endif()
1330 endif() 1365 endif()
1331 endforeach() 1366 endforeach()
1332 if(all_eo_gen_files) 1367 if(all_eo_gen_files)
@@ -1335,6 +1370,8 @@ function(EFL_CREATE_EO_RULES target generation_dir)
1335 DEPENDS ${all_eo_gen_files} 1370 DEPENDS ${all_eo_gen_files}
1336 ) 1371 )
1337 add_dependencies(${target} ${target}-eo) 1372 add_dependencies(${target} ${target}-eo)
1338 add_dependencies(${target}-eo eolian-bin) 1373 if(IN_TREE_EOLIAN)
1374 add_dependencies(${target}-eo eolian-bin)
1375 endif()
1339 endif() 1376 endif()
1340endfunction() 1377endfunction()