mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 21:15:56 +08:00
[Refactor] Modular CMake setup with unified module handling
[Add] JuiceModule.cmake function add_juice_module to create modules with source collection, include dirs, linking, and optional compile definitions [Change] Root CMakeLists.txt now calls add_juice_module for core, injector, loader; no need to repeat add_subdirectory per module [Change] target_compile_definitions for module-specific macros (e.g., agent) moved to function end to ensure target exists before setting [Improve] Simplified module management and build clarity
This commit is contained in:
1 parent
a11fbf76ab
commit
32f2d5c116
9 files changed
+45
-64
No files matched your search
@@ -0,0 +1,34 @@
|
||||
# JuiceModule.cmake
|
||||
# Function to add a JuiceAgent module (agent, injector, juiceloader)
|
||||
|
||||
function(add_juice_module NAME)
|
||||
link_directories("$ENV{JAVA_HOME}/lib")
|
||||
|
||||
# Collect all source files in module src and utils
|
||||
file(GLOB MODULE_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/src/${NAME}/*.c"
|
||||
"${CMAKE_SOURCE_DIR}/src/${NAME}/utils/*.c"
|
||||
)
|
||||
|
||||
# Create shared library
|
||||
add_library(${NAME} SHARED ${MODULE_SOURCES})
|
||||
|
||||
# Include directories
|
||||
target_include_directories(${NAME} PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/includes
|
||||
${CMAKE_SOURCE_DIR}/includes/jvm
|
||||
${CMAKE_SOURCE_DIR}/includes/jvm/win32
|
||||
${CMAKE_SOURCE_DIR}/includes/JuiceLoader
|
||||
${CMAKE_SOURCE_DIR}/includes/ReflectiveDLLInjection
|
||||
"${CMAKE_SOURCE_DIR}/src/${NAME}/utils"
|
||||
"${CMAKE_SOURCE_DIR}/src/${NAME}/include"
|
||||
)
|
||||
|
||||
# Link common libraries
|
||||
target_link_libraries(${NAME} PRIVATE
|
||||
ReflectiveDLLInjection
|
||||
jvm
|
||||
)
|
||||
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/src/${NAME}")
|
||||
endfunction()
|
||||
Reference in new issue
Block a user