2023-05-18 14:00:10 +01:00
|
|
|
add_library(resources headers.cpp)
|
|
|
|
|
|
|
|
target_include_directories(resources PRIVATE ../)
|
|
|
|
|
|
|
|
function(embed_headers output)
|
|
|
|
file(WRITE ${output} "#include \"oi/Headers.h\"\n\n")
|
|
|
|
file(APPEND ${output} "namespace ObjectIntrospection {\n")
|
|
|
|
file(APPEND ${output} "namespace headers {\n\n")
|
|
|
|
|
|
|
|
set(HEADERS
|
2023-06-26 11:07:44 +01:00
|
|
|
../include/oi/types/dy.h
|
2023-06-29 13:07:46 +01:00
|
|
|
../include/oi/types/st.h
|
2023-05-18 14:00:10 +01:00
|
|
|
../oi/OITraceCode.cpp
|
|
|
|
)
|
|
|
|
foreach(header ${HEADERS})
|
|
|
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${header})
|
2023-06-29 13:07:46 +01:00
|
|
|
|
2023-07-05 18:30:05 +01:00
|
|
|
file(REAL_PATH ${header} header_path)
|
|
|
|
file(REAL_PATH ${CMAKE_SOURCE_DIR}/include include_path)
|
|
|
|
file(REAL_PATH ${CMAKE_SOURCE_DIR} base_path)
|
2023-06-29 13:07:46 +01:00
|
|
|
|
2023-07-05 18:30:05 +01:00
|
|
|
cmake_path(IS_PREFIX include_path ${header_path} NORMALIZE in_include)
|
2023-06-29 13:07:46 +01:00
|
|
|
if (${in_include})
|
2023-07-05 18:30:05 +01:00
|
|
|
file(RELATIVE_PATH header_rel_path ${include_path} ${header_path})
|
2023-06-29 13:07:46 +01:00
|
|
|
else()
|
2023-07-05 18:30:05 +01:00
|
|
|
file(RELATIVE_PATH header_rel_path ${base_path} ${header_path})
|
2023-06-29 13:07:46 +01:00
|
|
|
endif()
|
|
|
|
|
2023-07-05 18:30:05 +01:00
|
|
|
string(MAKE_C_IDENTIFIER ${header_rel_path} varname)
|
2023-05-18 14:00:10 +01:00
|
|
|
get_filename_component(filename ${header} NAME)
|
2023-06-29 13:07:46 +01:00
|
|
|
|
2023-05-18 14:00:10 +01:00
|
|
|
file(READ ${header} contents)
|
|
|
|
file(APPEND ${output} "const std::string_view ${varname} = R\"CONTENTS(${contents})CONTENTS\";\n\n")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
file(APPEND ${output} "} // namespace headers\n")
|
|
|
|
file(APPEND ${output} "} // namespace ObjectIntrospection\n")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
embed_headers(${CMAKE_BINARY_DIR}/resources/headers.cpp)
|