You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.7 KiB

2 months ago
  1. find_package(Java REQUIRED COMPONENTS Runtime Development)
  2. find_package(JNI REQUIRED)
  3. find_package(SWIG 3.0 REQUIRED)
  4. include(UseJava)
  5. include(UseSWIG)
  6. file(GLOB_RECURSE i_files "swig/*.i")
  7. foreach(file ${i_files})
  8. SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES CPLUSPLUS 1)
  9. endforeach()
  10. #set(test_filenames "")
  11. #file(GLOB_RECURSE test_files "test/*.java")
  12. #foreach(file ${test_files})
  13. # get_filename_component(filename ${file} NAME_WE)
  14. # IF (NOT (${filename} MATCHES "TestCarl"))
  15. # set(test_filenames ${test_filenames} ${filename})
  16. # ENDIF ()
  17. #endforeach()
  18. #enable_testing()
  19. #compile the tests
  20. #ADD_CUSTOM_COMMAND(
  21. #OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test/*.class
  22. #COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test
  23. #COMMAND ${Java_JAVAC_EXECUTABLE} -d ${CMAKE_CURRENT_BINARY_DIR}/test -cp "${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_SOURCE_DIR}/test:${CMAKE_CURRENT_BINARY_DIR}/jcarl.jar:/usr/share/java/junit.jar"
  24. #${CMAKE_CURRENT_SOURCE_DIR}/test/*java
  25. #DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/*.java
  26. #)
  27. #build the jar
  28. ADD_CUSTOM_COMMAND(
  29. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/jcarl/jcarl.jar
  30. COMMAND ${Java_JAVAC_EXECUTABLE} ./jcarl/*.java
  31. COMMAND jar cvf jcarl.jar ./jcarl/*.class
  32. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/jcarl
  33. )
  34. #add_test(NAME jcarl COMMAND ${Java_JAVA_EXECUTABLE} -classpath .:/usr/share/java/junit.jar:/usr/share/java/hamcrest-core.jar:../ -Djava.library.path=../ org.junit.runner.JUnitCore ${test_filenames}
  35. #WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test )
  36. set(CMAKE_JNI_TARGET TRUE)
  37. #this is for swig
  38. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${JAVA_AWT_INCLUDE_PATH} -I${JAVA_AWT_INCLUDE_PATH}/linux -I/usr/include/python2.7")
  39. set(CMAKE_SWIG_FLAGS -package jcarl)
  40. set(CMAKE_SWIG_OUTDIR "jcarl/jcarl")
  41. swig_add_module(jcarl java ${i_files})
  42. swig_link_libraries(jcarl lib_carl)
  43. #For Python: Not working, however...
  44. #set(CMAKE_SWIG_FLAGS "")
  45. #set(CMAKE_SWIG_OUTDIR "pycarl/pycarl")
  46. #swig_add_module(pycarl python ${i_files})
  47. #swig_link_libraries(pycarl lib_carl)
  48. ADD_CUSTOM_TARGET(jcarl.jar
  49. ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/jcarl/jcarl.jar jcarl)
  50. #ADD_CUSTOM_TARGET(tests
  51. #ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/test/*.class ${CMAKE_CURRENT_BINARY_DIR}/jcarl.jar jcarl)
  52. #find_package(PythonInterp)
  53. #if (PYTHONINTERP_FOUND)
  54. # add_test( NAME pycarl COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/runAllTests.py)
  55. #else()
  56. # status(WARNING "Did not find a python interpreter, disabling pycarl tests.")
  57. #endif()
  58. # include dir: bindings/jcarl/example/
  59. # libraries: bindings/jcarl/*.jar / *.so
  60. # javac test.java
  61. # java -cp <jarfile>:. test
  62. #execute test from within test directory: java -Djava.library.path=../ -cp ../:. TestBindings