xmos / xcommon_cmake

6 stars 5 forks source link

library internal and external includes #25

Open xross opened 1 year ago

xross commented 1 year ago

For a lib, when using xcommon, a lib exports (via EXPORT_INCLUDE_DIRS) the API headers for the lib. It separately sets up internal includes for the lib (INCLUDE_DIRS). AFAIK cmake_xcommon only one variable for both (LIB_INCLUDES)

danielpieczko commented 1 year ago

When I was initially trying to replicate the xmake export functionality with an export directory, I was setting a LIB_EXPORT_SOURCE_DIRS variable, but in the end nothing happened with that so it is unused - that variable doesn't appear in xmos_utils.cmake. https://github.com/danielpieczko/cmake_xcommon/blob/main/tests/static_lib_arch/lib_stat/lib_stat/CMakeLists.txt#L7

xross commented 1 year ago

One problem we have at the moment is that the include paths get very long - we add LIB_INCLUDES via target_include_directories(executable) in REGISTER_MODULE().

It would be nicer if LIB_EXPORT_INCLUDES was added to the executable and LIB_INCLUDES added to the library. However, since we are not using add_library() in the normal case (only for static libs) I'm not sure of a nice alternative.

Setting 'SET_SOURCE_FILES_PROPERTIES(source_file PROPERTIES COMPILE_FLAGS -I/include/path)' seems rather horrid.