groundwork for standalone elfs of modules for debugging purposes
This commit is contained in:
@@ -3,18 +3,13 @@ project(info_module)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
# Set output directory for standalone builds
|
||||
# Set DPM_ROOT_DIR based on whether this is a standalone build or part of the main build
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
set(MODULE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/modules")
|
||||
set(DPM_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
||||
else()
|
||||
set(MODULE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/modules")
|
||||
set(DPM_ROOT_DIR "${CMAKE_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
# Create output directory
|
||||
file(MAKE_DIRECTORY ${MODULE_OUTPUT_DIR})
|
||||
|
||||
# Create shared library
|
||||
add_library(info MODULE
|
||||
info.cpp
|
||||
@@ -26,11 +21,31 @@ set_target_properties(
|
||||
info PROPERTIES
|
||||
PREFIX ""
|
||||
SUFFIX ".so"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${MODULE_OUTPUT_DIR}"
|
||||
)
|
||||
|
||||
# Include directories
|
||||
target_include_directories(info PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${DPM_ROOT_DIR}
|
||||
)
|
||||
|
||||
# Standalone version - used for debugging
|
||||
add_executable(info_standalone
|
||||
info.cpp
|
||||
src/infoFuncs.cpp
|
||||
)
|
||||
|
||||
# Define the BUILD_STANDALONE macro for the standalone build
|
||||
target_compile_definitions(info_standalone PRIVATE BUILD_STANDALONE)
|
||||
|
||||
# Include directories for standalone
|
||||
target_include_directories(info_standalone PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${DPM_ROOT_DIR}
|
||||
)
|
||||
|
||||
# Set the output name for the standalone executable
|
||||
set_target_properties(
|
||||
info_standalone PROPERTIES
|
||||
OUTPUT_NAME "info_debug"
|
||||
)
|
||||
@@ -108,3 +108,8 @@ extern "C" int dpm_module_execute(const char* command, int argc, char** argv) {
|
||||
return cmd_unknown(command, argc, argv);
|
||||
}
|
||||
}
|
||||
|
||||
// If we're building in standalone mode, include the main function
|
||||
#ifdef BUILD_STANDALONE
|
||||
DPM_MODULE_STANDALONE_MAIN()
|
||||
#endif // BUILD_STANDALONE
|
||||
Reference in New Issue
Block a user