openbabel-python-2.3.2-bindings_only.patch 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index 449f4b4..1c9ad00 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -252,7 +252,8 @@ if(NOT MSVC)
  6. }
  7. " SCANDIR_NEEDS_CONST)
  8. - set(OB_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/${OB_PLUGIN_INSTALL_DIR}")
  9. + set(OB_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/${OB_PLUGIN_INSTALL_DIR}"
  10. + CACHE PATH "Set to system install for bindings only build")
  11. add_definitions(-DOB_MODULE_PATH="\\"${OB_MODULE_PATH}\\"")
  12. # Add some visibility support when using GCC
  13. @@ -380,7 +381,8 @@ if(UNIX AND BUILD_SHARED)
  14. if(APPLE)
  15. set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR})
  16. else()
  17. - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
  18. + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}"
  19. + CACHE PATH "Set sane rpath")
  20. set(CMAKE_SKIP_BUILD_RPATH FALSE)
  21. set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  22. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  23. @@ -477,6 +479,13 @@ endif()
  24. # Should the language bindings be regenereted?
  25. option(RUN_SWIG "Generate language bindings with SWIG" OFF)
  26. +# Build bindings only
  27. +option(BINDINGS_ONLY "Build bindings only" OFF)
  28. +
  29. +# Point to library if building bindings only
  30. +set(BABEL_SYSTEM_LIBRARY ${BABEL_LIBRARY}
  31. + CACHE PATH "Point to openbabel library if building bindings only")
  32. +
  33. # Should all bindings be built?
  34. option(ALL_BINDINGS "Build all languages bindings" OFF)
  35. diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
  36. index 16e9000..ecd2295 100644
  37. --- a/scripts/CMakeLists.txt
  38. +++ b/scripts/CMakeLists.txt
  39. @@ -92,16 +92,30 @@ if (DO_PYTHON_BINDINGS)
  40. endif(RUN_SWIG)
  41. add_library(bindings_python MODULE ${openbabel_SOURCE_DIR}/scripts/python/openbabel-python.cpp)
  42. - target_link_libraries(bindings_python ${PYTHON_LIBRARIES} ${BABEL_LIBRARY})
  43. + if(BINDINGS_ONLY)
  44. + target_link_libraries(bindings_python ${PYTHON_LIBRARIES} ${BABEL_SYSTEM_LIBRARY})
  45. + else()
  46. + target_link_libraries(bindings_python ${PYTHON_LIBRARIES} ${BABEL_LIBRARY})
  47. + endif()
  48. +
  49. if(NOT WIN32)
  50. set_target_properties(bindings_python PROPERTIES
  51. OUTPUT_NAME _openbabel
  52. PREFIX ""
  53. SUFFIX .so )
  54. - add_dependencies(bindings_python openbabel)
  55. - install(TARGETS bindings_python LIBRARY DESTINATION ${LIB_INSTALL_DIR})
  56. - install(FILES ${openbabel_SOURCE_DIR}/scripts/python/openbabel.py DESTINATION ${LIB_INSTALL_DIR})
  57. - install(FILES ${openbabel_SOURCE_DIR}/scripts/python/pybel.py DESTINATION ${LIB_INSTALL_DIR})
  58. + if(NOT BINDINGS_ONLY)
  59. + add_dependencies(bindings_python openbabel)
  60. + endif()
  61. +
  62. + install(TARGETS bindings_python
  63. + LIBRARY DESTINATION ${LIB_INSTALL_DIR}
  64. + COMPONENT bindings_python)
  65. + install(FILES ${openbabel_SOURCE_DIR}/scripts/python/openbabel.py
  66. + DESTINATION ${LIB_INSTALL_DIR}
  67. + COMPONENT bindings_python)
  68. + install(FILES ${openbabel_SOURCE_DIR}/scripts/python/pybel.py
  69. + DESTINATION ${LIB_INSTALL_DIR}
  70. + COMPONENT bindings_python)
  71. else(NOT WIN32)
  72. set_target_properties(bindings_python PROPERTIES
  73. OUTPUT_NAME _openbabel
  74. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
  75. index 7841782..6f3495f 100644
  76. --- a/test/CMakeLists.txt
  77. +++ b/test/CMakeLists.txt
  78. @@ -2,7 +2,12 @@
  79. add_definitions(-DTESTDATADIR="\\"${CMAKE_SOURCE_DIR}/test/files/\\"")
  80. # define FORMATDIR for location of format plugin binaries
  81. -add_definitions(-DFORMATDIR="\\"${openbabel_BINARY_DIR}/lib/\\"")
  82. +if(BINDINGS_ONLY)
  83. + set(FORMATDIR "${OB_MODULE_PATH}/")
  84. +else()
  85. + set(FORMATDIR "${openbabel_BINARY_DIR}/lib${LIB_SUFFIX}/")
  86. +endif()
  87. +add_definitions(-DFORMATDIR="\\"${FORMATDIR}/\\"")
  88. ###########################################################
  89. # new tests using obtest.h
  90. @@ -89,7 +94,7 @@ foreach(test ${tests})
  91. add_test(${test}_Test ${TEST_PATH}/test_${test})
  92. set_tests_properties(${test}_Test PROPERTIES
  93. FAIL_REGULAR_EXPRESSION "ERROR;FAIL;Test failed"
  94. - ENVIRONMENT "BABEL_DATADIR=${CMAKE_SOURCE_DIR}/data;LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib")
  95. + ENVIRONMENT "BABEL_DATADIR=${CMAKE_SOURCE_DIR}/data;LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}")
  96. endforeach(test ${tests})
  97. ############################################################
  98. @@ -152,7 +157,7 @@ if(WITH_INCHI)
  99. ${TEST_PATH}/test_inchiwrite ${inchidata}/${test} ${inchidata}/${test}.txt)
  100. set_tests_properties(inchi${test}_Test PROPERTIES
  101. FAIL_REGULAR_EXPRESSION "Not ok"
  102. - ENVIRONMENT "BABEL_DATADIR=${CMAKE_SOURCE_DIR}/data;LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib"
  103. + ENVIRONMENT "BABEL_DATADIR=${CMAKE_SOURCE_DIR}/data;LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}"
  104. )
  105. endforeach(test ${inchitests})
  106. endif(WITH_INCHI)
  107. @@ -166,7 +171,7 @@ foreach(test ${old_tests})
  108. add_test(${test}_Test ${TEST_PATH}/test_${test})
  109. set_tests_properties(${test}_Test PROPERTIES
  110. FAIL_REGULAR_EXPRESSION "not ok"
  111. - ENVIRONMENT "BABEL_DATADIR=${CMAKE_SOURCE_DIR}/data;LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib"
  112. + ENVIRONMENT "BABEL_DATADIR=${CMAKE_SOURCE_DIR}/data;LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}"
  113. )
  114. endforeach(test ${old_tests})
  115. @@ -181,8 +186,8 @@ if(NOT BUILD_SHARED AND NOT BUILD_MIXED)
  116. endif()
  117. install(TARGETS roundtrip
  118. RUNTIME DESTINATION bin
  119. - LIBRARY DESTINATION lib
  120. - ARCHIVE DESTINATION lib
  121. + LIBRARY DESTINATION lib${LIB_SUFFIX}
  122. + ARCHIVE DESTINATION lib${LIB_SUFFIX}
  123. )
  124. ###########################
  125. @@ -199,10 +204,10 @@ if(NOT MINGW AND NOT CYGWIN)
  126. babel sym smartssym fastsearch unique kekule)
  127. foreach(pytest ${pytests})
  128. SET_SOURCE_FILES_PROPERTIES(test${pytest}.py PROPERTIES
  129. - PYTHONPATH "${CMAKE_SOURCE_DIR}/scripts/python:${CMAKE_BINARY_DIR}/lib"
  130. - BABEL_LIBDIR "${CMAKE_BINARY_DIR}/lib"
  131. + PYTHONPATH "${CMAKE_SOURCE_DIR}/scripts/python:${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}"
  132. + BABEL_LIBDIR "${FORMATDIR}"
  133. BABEL_DATADIR "${CMAKE_SOURCE_DIR}/data"
  134. - LD_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib"
  135. + LD_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}"
  136. )
  137. ADD_PYTHON_TEST(pytest_${pytest} test${pytest}.py)
  138. set_tests_properties(pytest_${pytest} PROPERTIES
  139. @@ -221,10 +226,10 @@ if (PYTHON_BINDINGS)
  140. bindings _pybel example)
  141. foreach(pybindtest ${pybindtests})
  142. SET_SOURCE_FILES_PROPERTIES(test${pybindtest}.py PROPERTIES
  143. - PYTHONPATH "${CMAKE_SOURCE_DIR}/scripts/python:${CMAKE_BINARY_DIR}/lib"
  144. - BABEL_LIBDIR "${CMAKE_BINARY_DIR}/lib"
  145. + PYTHONPATH "${CMAKE_SOURCE_DIR}/scripts/python:${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}"
  146. + BABEL_LIBDIR "${FORMATDIR}"
  147. BABEL_DATADIR "${CMAKE_SOURCE_DIR}/data"
  148. - LD_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib"
  149. + LD_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}"
  150. )
  151. if(MSVC)
  152. SET_SOURCE_FILES_PROPERTIES(test${pybindtest}.py PROPERTIES
  153. diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
  154. index 1f547bf..fb98441 100644
  155. --- a/tools/CMakeLists.txt
  156. +++ b/tools/CMakeLists.txt
  157. @@ -38,8 +38,8 @@ if(BUILD_SHARED)
  158. target_link_libraries(${tool} ${BABEL_LIBRARY})
  159. install(TARGETS ${tool}
  160. RUNTIME DESTINATION bin
  161. - LIBRARY DESTINATION lib
  162. - ARCHIVE DESTINATION lib
  163. + LIBRARY DESTINATION lib${LIB_SUFFIX}
  164. + ARCHIVE DESTINATION lib${LIB_SUFFIX}
  165. )
  166. endforeach(tool)
  167. @@ -53,8 +53,8 @@ if(BUILD_SHARED)
  168. target_link_libraries(obspectrophore ${BABEL_LIBRARY})
  169. install(TARGETS obspectrophore
  170. RUNTIME DESTINATION bin
  171. - LIBRARY DESTINATION lib
  172. - ARCHIVE DESTINATION lib
  173. + LIBRARY DESTINATION lib${LIB_SUFFIX}
  174. + ARCHIVE DESTINATION lib${LIB_SUFFIX}
  175. )
  176. # obgrep -- requires getopt
  177. @@ -66,8 +66,8 @@ if(BUILD_SHARED)
  178. target_link_libraries(obgrep ${BABEL_LIBRARY})
  179. install(TARGETS obgrep
  180. RUNTIME DESTINATION bin
  181. - LIBRARY DESTINATION lib
  182. - ARCHIVE DESTINATION lib
  183. + LIBRARY DESTINATION lib${LIB_SUFFIX}
  184. + ARCHIVE DESTINATION lib${LIB_SUFFIX}
  185. )
  186. endif(NOT MINIMAL_BUILD)
  187. @@ -146,7 +146,7 @@ else(BUILD_SHARED)
  188. install(TARGETS babel
  189. RUNTIME DESTINATION bin
  190. - LIBRARY DESTINATION lib
  191. - ARCHIVE DESTINATION lib)
  192. + LIBRARY DESTINATION lib${LIB_SUFFIX}
  193. + ARCHIVE DESTINATION lib${LIB_SUFFIX})
  194. endif(BUILD_SHARED)