CMakeLists.txt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. FIND_PACKAGE(SWIG REQUIRED)
  2. INCLUDE(UseSWIG)
  3. if(ENABLE_BINDING_LUA)
  4. FIND_PACKAGE(Lua51)
  5. file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/lua)
  6. add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/lua/lua_wrap.c
  7. COMMAND ${SWIG_EXECUTABLE} -lua
  8. -I${PROJECT_SOURCE_DIR}/include
  9. -o ${PROJECT_BINARY_DIR}/lua/lua_wrap.c
  10. ${PROJECT_SOURCE_DIR}/bindings/open62541.i
  11. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/open62541.i)
  12. add_library(open62541-lua SHARED ${PROJECT_BINARY_DIR}/lua/lua_wrap.c)
  13. set_target_properties(open62541-lua PROPERTIES COMPILE_FLAGS "-Wno-error")
  14. target_include_directories(open62541-lua PUBLIC ${LUA_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include
  15. ${PROJECT_BINARY_DIR}/src_generated)
  16. target_link_libraries(open62541-lua open62541-static)
  17. set_target_properties(open62541-lua PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lua
  18. OUTPUT_NAME open62541 PREFIX "")
  19. endif()
  20. if(ENABLE_BINDING_PYTHON)
  21. FIND_PACKAGE(PythonLibs)
  22. file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/python)
  23. add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/python/python_wrap.c
  24. COMMAND ${SWIG_EXECUTABLE} -python
  25. -I${PROJECT_SOURCE_DIR}/include
  26. -o ${PROJECT_BINARY_DIR}/python/python_wrap.c
  27. ${PROJECT_SOURCE_DIR}/bindings/open62541.i
  28. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/open62541.i)
  29. add_library(open62541-python SHARED ${PROJECT_BINARY_DIR}/python/python_wrap.c)
  30. set_target_properties(open62541-python PROPERTIES COMPILE_FLAGS "-Wno-error")
  31. target_include_directories(open62541-python PUBLIC ${PYTHON_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include
  32. ${PROJECT_BINARY_DIR}/src_generated)
  33. target_link_libraries(open62541-python open62541-static)
  34. set_target_properties(open62541-python PROPERTIES
  35. LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/python
  36. OUTPUT_NAME _open62541 PREFIX "")
  37. endif()