Skip to content

Commit 9c8bf78

Browse files
committed
Fix Java core-models build script
This fixes two problems with the core-models build script: 1. Use of add_library with target_source_files listing the same source led to including the *source* files along with every build target, hence multiple builds of the same file 2. Using add_custom_command to create a pre-build hook instead of a normal file-producing command meant java_class_loader.cpp and its dependencies were rebuilt on every build.
1 parent b0cb1ee commit 9c8bf78

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/java_bytecode/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ add_subdirectory(library)
77

88
add_library(java_bytecode ${sources} ${headers} )
99
add_dependencies(java_bytecode core_models_files)
10-
target_sources(java_bytecode PUBLIC ${sources} ${headers})
1110

1211
generic_includes(java_bytecode)
1312

src/java_bytecode/library/CMakeLists.txt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ set(CMAKE_JAVA_COMPILE_FLAGS -sourcepath "src" -d "classes" -XDignore.symbol.fil
44
file(GLOB_RECURSE java_sources "*.java")
55
set(JAR_NAME "core-models")
66
add_jar(${JAR_NAME} ${java_sources})
7-
get_filename_component(CORE_MODELS_JAR "core-models.jar" REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
7+
get_filename_component(CORE_MODELS_JAR "core-models.jar" REALPATH BASE_DIR ${CMAKE_CURRENT_BINARY_DIR})
88
get_filename_component(JAVA_CORE_MODELS_INC "java_core_models.inc" REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
9-
file(GLOB_RECURSE jars "*.jar")
109
add_executable(java-converter converter.cpp)
1110

12-
add_custom_target(core_models_files)
13-
add_dependencies(core_models_files ${JAR_NAME})
14-
add_custom_command(TARGET core_models_files
15-
PRE_BUILD
16-
COMMAND java-converter JAVA_CORE_MODELS core-models.jar > ${JAVA_CORE_MODELS_INC}
17-
)
11+
add_custom_command(OUTPUT ${JAVA_CORE_MODELS_INC}
12+
COMMAND java-converter JAVA_CORE_MODELS ${CORE_MODELS_JAR} > ${JAVA_CORE_MODELS_INC}
13+
MAIN_DEPENDENCY ${CORE_MODELS_JAR})
1814

19-
set_source_files_properties("java_core_models.inc" GENERATED)
15+
add_custom_target(core_models_files
16+
DEPENDS ${JAVA_CORE_MODELS_INC})

0 commit comments

Comments
 (0)