docs: Update 7 files
This commit is contained in:
@@ -46,28 +46,45 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
file(GLOB_RECURSE HEADERS "src/*.hpp")
|
||||
|
||||
# Add custom target to run cmake_prebuild.sh at the start of the build process
|
||||
add_custom_target(run_prebuild_script ALL
|
||||
# Define the generated output files
|
||||
set(AGENT_REMOTE_CPP ${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-remote.cpp)
|
||||
set(AGENT_LOCAL_CPP ${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-local.cpp)
|
||||
|
||||
# Get list of input files that trigger regeneration
|
||||
file(GLOB AGENT_REMOTE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/agent-remote/*")
|
||||
file(GLOB AGENT_LOCAL_FILES "${CMAKE_CURRENT_SOURCE_DIR}/agent-local/*")
|
||||
|
||||
# Custom command with proper dependency tracking
|
||||
# Runs cmake_prebuild.sh only when input files change or outputs are missing
|
||||
add_custom_command(
|
||||
OUTPUT ${AGENT_REMOTE_CPP} ${AGENT_LOCAL_CPP}
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Running cmake_prebuild.sh..."
|
||||
COMMAND ${CMAKE_COMMAND} -E env bash ${CMAKE_CURRENT_SOURCE_DIR}/cmake_prebuild.sh
|
||||
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/cmake_prebuild.sh
|
||||
DEPENDS
|
||||
${AGENT_REMOTE_FILES}
|
||||
${AGENT_LOCAL_FILES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake_prebuild.sh
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Generating agent source files from agent-remote/ and agent-local/"
|
||||
)
|
||||
|
||||
# Custom target for manual invocation (e.g., "ninja run_prebuild_script")
|
||||
add_custom_target(run_prebuild_script DEPENDS ${AGENT_REMOTE_CPP} ${AGENT_LOCAL_CPP})
|
||||
|
||||
# Add executable
|
||||
add_executable(dropshell ${SOURCES})
|
||||
add_dependencies(dropshell run_prebuild_script)
|
||||
|
||||
# Mark the generated files as GENERATED so CMake knows they'll be created during build
|
||||
set_source_files_properties(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-remote.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-local.cpp
|
||||
${AGENT_REMOTE_CPP}
|
||||
${AGENT_LOCAL_CPP}
|
||||
PROPERTIES GENERATED TRUE
|
||||
)
|
||||
|
||||
# Explicitly add the generated agent files, as they might not be in the source directory when globbed at the start.
|
||||
# Explicitly add the generated agent files
|
||||
target_sources(dropshell PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-remote.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-local.cpp
|
||||
${AGENT_REMOTE_CPP}
|
||||
${AGENT_LOCAL_CPP}
|
||||
)
|
||||
|
||||
# Set include directories
|
||||
|
||||
Reference in New Issue
Block a user