CMakeLists.txt 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. cmake_minimum_required(VERSION 3.2)
  2. project(ZeroTierOneJNI)
  3. find_package(Java COMPONENTS Development)
  4. message("JAVA_HOME: $ENV{JAVA_HOME}")
  5. if(WIN32)
  6. set(Java_INCLUDE_DIRS $ENV{JAVA_HOME}/include)
  7. endif()
  8. if(APPLE)
  9. set(Java_INCLUDE_DIRS "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/JavaVM.framework/Headers")
  10. endif()
  11. message("Java Include Dirs: ${Java_INCLUDE_DIRS}")
  12. if(WIN32)
  13. add_definitions(-DNOMINMAX)
  14. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /W3 /MP")
  15. endif()
  16. if(APPLE)
  17. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch i386 -arch x86_64 -Wall -O3 -flto -fPIE -fvectorize -fstack-protector -mmacosx-version-min=10.7 -Wno-unused-private-field")
  18. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -fno-rtti")
  19. endif()
  20. set(src_files
  21. ../ext/lz4/lz4.c
  22. ../ext/json-parser/json.c
  23. ../ext/http-parser/http_parser.c
  24. ../node/C25519.cpp
  25. ../node/CertificateOfMembership.cpp
  26. ../node/Defaults.cpp
  27. ../node/Dictionary.cpp
  28. ../node/Identity.cpp
  29. ../node/IncomingPacket.cpp
  30. ../node/InetAddress.cpp
  31. ../node/Multicaster.cpp
  32. ../node/Network.cpp
  33. ../node/NetworkConfig.cpp
  34. ../node/Node.cpp
  35. ../node/OutboundMulticast.cpp
  36. ../node/Packet.cpp
  37. ../node/Peer.cpp
  38. ../node/Poly1305.cpp
  39. ../node/Salsa20.cpp
  40. ../node/SelfAwareness.cpp
  41. ../node/SHA512.cpp
  42. ../node/Switch.cpp
  43. ../node/Topology.cpp
  44. ../node/Utils.cpp
  45. ../osdep/Http.cpp
  46. ../osdep/OSUtils.cpp
  47. jni/com_zerotierone_sdk_Node.cpp
  48. jni/ZT_jniutils.cpp
  49. jni/ZT_jnicache.cpp
  50. )
  51. set(include_dirs
  52. ${CMAKE_CURRENT_SOURCE_DIR}/../include/
  53. ${CMAKE_CURRENT_SOURCE_DIR}/../node/
  54. ${Java_INCLUDE_DIRS})
  55. if(WIN32)
  56. set(include_dirs
  57. ${include_dirs}
  58. ${Java_INCLUDE_DIRS}/win32)
  59. endif()
  60. include_directories(
  61. ${include_dirs}
  62. )
  63. add_library(${PROJECT_NAME} SHARED ${src_files})
  64. if(APPLE)
  65. set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".jnilib")
  66. endif()
  67. set(link_libs )
  68. if(WIN32)
  69. set(link_libs
  70. wsock32
  71. ws2_32
  72. )
  73. endif()
  74. target_link_libraries(${PROJECT_NAME} ${link_libs})