Fix Inchi being hardcoded into PostgreSQL (#1009)

* - this should fix the problem with "Inchi" being hardcoded into PostgreSQL

* - moved the InChI check code out of the main CMakeLists.txt
  into FindInchi.cmake
This commit is contained in:
Paolo Tosco
2016-08-08 10:22:56 +01:00
committed by Greg Landrum
parent cb710340a1
commit 5d3bb11488
4 changed files with 80 additions and 79 deletions

View File

@@ -1,92 +1,50 @@
add_custom_target(inchi_support ALL)
if(RDK_BUILD_INCHI_SUPPORT)
# search system InChI
find_package(Inchi)
# check whether we have custom InChI source
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/ichican2.c)
message(STATUS "Found InChI software locally")
if(INCHI_FOUND)
message(WARNING "** Local InChI software takes precedence when both system InChI and local InChI are found")
endif(INCHI_FOUND)
else(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/ichican2.c)
if (INCHI_FOUND)
include_directories(${INCHI_INCLUDE_DIR})
else (INCHI_FOUND)
# system InChI is missing, download it
if(NOT DEFINED INCHI_URL)
set(INCHI_URL "http://www.inchi-trust.org/wp/wp-content/uploads/2014/06/INCHI-1-API.zip")
endif()
if(NOT DEFINED INCHI_MD5SUM)
set(INCHI_MD5SUM "8447bf108af12fe66eecba41bbc89918")
endif()
if(NOT DEFINED INCHI_BASE)
string(REGEX REPLACE "^.*/" "" INCHI_BASE "${INCHI_URL}")
endif()
downloadAndCheckMD5(${INCHI_URL} "${CMAKE_CURRENT_SOURCE_DIR}/${INCHI_BASE}" ${INCHI_MD5SUM})
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf
${CMAKE_CURRENT_SOURCE_DIR}/INCHI-1-API.zip
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/INCHI-1-API/INCHI_API/inchi_dll" "${CMAKE_CURRENT_SOURCE_DIR}/src")
endif(INCHI_FOUND)
endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/ichican2.c)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/ichican2.c)
rdkit_library(Inchi src/ichican2.c src/ichicano.c
src/ichicans.c src/ichiisot.c
src/ichilnct.c src/ichimak2.c
src/ichimake.c src/ichimap1.c
src/ichimap2.c src/ichimap4.c
src/ichinorm.c src/ichiparm.c
src/ichiprt1.c src/ichiprt2.c
src/ichiprt3.c src/ichiqueu.c
src/ichiring.c src/ichisort.c
src/ichister.c src/ichitaut.c
src/ichi_bns.c src/inchi_dll.c
src/ichiread.c src/ichirvr1.c
src/ichirvr2.c src/ichirvr3.c
src/ichirvr4.c src/ichirvr5.c
src/ichirvr6.c src/ichirvr7.c
src/inchi_dll_main.c src/runichi.c
src/inchi_dll_a.c src/inchi_dll_a2.c
src/ikey_dll.c src/ikey_base26.c
src/ichi_io.c
src/sha2.c src/strutil.c
src/util.c SHARED)
install(TARGETS Inchi DESTINATION ${RDKit_LibDir})
set(INCHI_LIBRARIES Inchi)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
else()
if(NOT INCHI_FOUND)
message(WARNING "** NO INCHI SOFTWARE FOUND\n"
"InChI support will be turned off. If you want to add InChI support, please follow the instructions inside $RDBASE/External/INCHI-API/README to download a copy of InChI software and then rerun cmake.")
set(RDK_BUILD_INCHI_SUPPORT OFF)
endif()
endif()
endif(RDK_BUILD_INCHI_SUPPORT)
if(RDK_BUILD_INCHI_SUPPORT AND
EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/ichican2.c)
rdkit_library(Inchi src/ichican2.c src/ichicano.c
src/ichicans.c src/ichiisot.c
src/ichilnct.c src/ichimak2.c
src/ichimake.c src/ichimap1.c
src/ichimap2.c src/ichimap4.c
src/ichinorm.c src/ichiparm.c
src/ichiprt1.c src/ichiprt2.c
src/ichiprt3.c src/ichiqueu.c
src/ichiring.c src/ichisort.c
src/ichister.c src/ichitaut.c
src/ichi_bns.c src/inchi_dll.c
src/ichiread.c src/ichirvr1.c
src/ichirvr2.c src/ichirvr3.c
src/ichirvr4.c src/ichirvr5.c
src/ichirvr6.c src/ichirvr7.c
src/inchi_dll_main.c src/runichi.c
src/inchi_dll_a.c src/inchi_dll_a2.c
src/ikey_dll.c src/ikey_base26.c
src/ichi_io.c
src/sha2.c src/strutil.c
src/util.c SHARED)
install(TARGETS Inchi DESTINATION ${RDKit_LibDir})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
endif()
# check whether InChI support is ON after the search
if(RDK_BUILD_INCHI_SUPPORT)
rdkit_library(RDInchiLib inchi.cpp SHARED LINK_LIBRARIES ${INCHI_LIBRARIES}
GraphMol RDGeneral Depictor SubstructMatch SmilesParse
${RDKit_THREAD_LIBS})
rdkit_headers(inchi.h DEST GraphMol)
if(RDK_BUILD_PYTHON_WRAPPERS)
add_subdirectory(Wrap)
endif(RDK_BUILD_PYTHON_WRAPPERS)
rdkit_library(RDInchiLib inchi.cpp SHARED LINK_LIBRARIES ${INCHI_LIBRARIES}
GraphMol RDGeneral Depictor SubstructMatch SmilesParse
${RDKit_THREAD_LIBS})
rdkit_headers(inchi.h DEST GraphMol)
if(RDK_BUILD_PYTHON_WRAPPERS)
add_subdirectory(Wrap)
endif(RDK_BUILD_PYTHON_WRAPPERS)
add_definitions(-DBUILD_INCHI_SUPPORT)
add_definitions(-DBUILD_INCHI_SUPPORT)
rdkit_test(testInchi test.cpp
LINK_LIBRARIES
${INCHI_LIBRARIES}
LINK_LIBRARIES
${INCHI_LIBRARIES}
RDInchiLib ${INCHI_LIBRARIES}
FileParsers SmilesParse Descriptors Depictor SubstructMatch GraphMol
RDGeneral DataStructs RDGeneral RDGeometryLib
${RDKit_THREAD_LIBS})
endif(RDK_BUILD_INCHI_SUPPORT)
if(RDK_BUILD_PYTHON_WRAPPERS)
# we need an inchi.py... copy in the appropriate one