forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request diffblue#1785 from smowton/smowton/fix/core-models…
…-cmake-script Fix Java core-models build script
- Loading branch information
Showing
2 changed files
with
29 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
get_filename_component(JAVA_CORE_MODELS_INC "library/java_core_models.inc" REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
set_source_files_properties("library/java_core_models.inc" GENERATED) | ||
# include here the targets defined in library/ | ||
add_subdirectory(library) | ||
|
||
# target 'java_bytecode' depends on all .cpp and .h files | ||
file(GLOB sources "*.cpp") | ||
file(GLOB_RECURSE headers "*.h") | ||
add_subdirectory(library) | ||
|
||
add_library(java_bytecode ${sources} ${headers} ) | ||
add_dependencies(java_bytecode core_models_files) | ||
add_library(java_bytecode ${sources} ${headers}) | ||
|
||
# define the include directories (passed to the compiler with -I) that those | ||
# targets wishing to depend on the target 'java_bytecode' may want to use | ||
generic_includes(java_bytecode) | ||
|
||
# target 'java-core-models-inc' is defined in library/ | ||
add_dependencies(java_bytecode java-core-models-inc) | ||
|
||
# if you link java_bytecode.a in, then you also need to link other .a libraries | ||
# in | ||
target_link_libraries(java_bytecode util goto-programs miniz json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
find_package(Java REQUIRED) | ||
include(UseJava) | ||
set(CMAKE_JAVA_COMPILE_FLAGS -sourcepath "src" -d "classes" -XDignore.symbol.file) | ||
file(GLOB_RECURSE java_sources "*.java") | ||
set(JAR_NAME "core-models") | ||
add_jar(${JAR_NAME} ${java_sources}) | ||
get_filename_component(CORE_MODELS_JAR "core-models.jar" REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
get_filename_component(JAVA_CORE_MODELS_INC "java_core_models.inc" REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
file(GLOB_RECURSE jars "*.jar") | ||
|
||
# create a target for the executable performing the .jar -> .inc conversion | ||
add_executable(java-converter converter.cpp) | ||
|
||
add_custom_target(core_models_files) | ||
add_dependencies(core_models_files ${JAR_NAME}) | ||
add_custom_command(TARGET core_models_files | ||
PRE_BUILD | ||
COMMAND java-converter JAVA_CORE_MODELS core-models.jar > ${JAVA_CORE_MODELS_INC} | ||
) | ||
# create a target 'core-models.jar' that depends on all .java files in src/ | ||
file(GLOB_RECURSE java_sources "src/*.java") | ||
add_jar("core-models" ${java_sources}) | ||
|
||
# define a cmake variable with the full path of the .inc file | ||
set(JAVA_CORE_MODELS_INC "${CMAKE_CURRENT_BINARY_DIR}/java_core_models.inc") | ||
|
||
# define a rule telling cmake how to generate the file ${JAVA_CORE_MODELS_INC} from | ||
# the .jar file by running the java-converter; the output file depends on the | ||
# .jar file but also on the converter (!) | ||
add_custom_command(OUTPUT ${JAVA_CORE_MODELS_INC} | ||
COMMAND java-converter "JAVA_CORE_MODELS" "core-models.jar" > ${JAVA_CORE_MODELS_INC} | ||
DEPENDS "core-models.jar" java-converter) | ||
|
||
set_source_files_properties("java_core_models.inc" GENERATED) | ||
# create a target 'core-models-inc' that depends on the .inc file | ||
add_custom_target(java-core-models-inc | ||
DEPENDS ${JAVA_CORE_MODELS_INC}) |