add heload, mid commit
This commit is contained in:
34
heload/CMakeLists.txt
Normal file
34
heload/CMakeLists.txt
Normal file
@@ -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
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # During build
|
||||
$<INSTALL_INTERFACE:include> # 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)
|
||||
7
heload/include/heload/heload.h
Normal file
7
heload/include/heload/heload.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef HELOAD_H_
|
||||
#define HELOAD_H_
|
||||
|
||||
void print_module_info(const char *module_name);
|
||||
|
||||
|
||||
#endif // HELOAD_H_
|
||||
15
heload/src/heload.c
Normal file
15
heload/src/heload.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "heload/heload.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
#include <link.h>
|
||||
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user