diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ceb3c2..9b1f67c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_STANDARD 17) add_subdirectory(3rd/SDL EXCLUDE_FROM_ALL) +add_subdirectory(heload) add_subdirectory(hiisi) target_link_options(SDL3-shared PRIVATE -Wl,-z,nodelete) @@ -13,4 +14,4 @@ target_link_options(SDL3-shared PRIVATE -Wl,-z,nodelete) add_executable(hiisi-run hiisi/main.cpp) -target_link_libraries(hiisi-run) +target_link_libraries(hiisi-run heload) diff --git a/heload/CMakeLists.txt b/heload/CMakeLists.txt new file mode 100644 index 0000000..b039eb0 --- /dev/null +++ b/heload/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.21) +project(Heload) + +# I just like to have this with my tooling +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_C_STANDARD 99) + +add_library(heload SHARED + src/heload.c +) + +# Specify the public headers location +target_include_directories(heload PUBLIC + $ # During build + $ # When installed +) + +install(TARGETS heload + EXPORT heloadTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) + +# Install header files +install(DIRECTORY include/ DESTINATION include) + +# Export the library for find_package() +install(EXPORT heloadTargets + FILE heloadConfig.cmake + DESTINATION lib/cmake/heload +) + +export(TARGETS heload FILE heloadConfig.cmake) diff --git a/heload/include/heload/heload.h b/heload/include/heload/heload.h new file mode 100644 index 0000000..3b65fac --- /dev/null +++ b/heload/include/heload/heload.h @@ -0,0 +1,7 @@ +#ifndef HELOAD_H_ +#define HELOAD_H_ + +void print_module_info(const char *module_name); + + +#endif // HELOAD_H_ diff --git a/heload/src/heload.c b/heload/src/heload.c new file mode 100644 index 0000000..957d358 --- /dev/null +++ b/heload/src/heload.c @@ -0,0 +1,15 @@ +#include "heload/heload.h" + +#include +#include +#include +#include + + +void print_module_info(const char *module_name) { + void *module = dlopen(module_name, RTLD_NOW); + + struct Lmid_t *lmid; + dlinfo(module, RTLD_DI_LMID, lmid); + +} diff --git a/hiisi/main.cpp b/hiisi/main.cpp index b657138..313740f 100644 --- a/hiisi/main.cpp +++ b/hiisi/main.cpp @@ -1,4 +1,5 @@ #include "hiisi.h" +#include "heload/heload.h" #include #include