diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a2e18fd3..a53e96414 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,6 +127,10 @@ if(MSVC) ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB") endif(MSVC) +if(RDK_BUILD_INCHI_SUPPORT) + find_package(Inchi) +endif(RDK_BUILD_INCHI_SUPPORT) + if(RDK_BUILD_PYTHON_WRAPPERS) #------- # pull in python: diff --git a/Code/PgSQL/rdkit/CMakeLists.txt b/Code/PgSQL/rdkit/CMakeLists.txt index d71718527..2e5b46541 100644 --- a/Code/PgSQL/rdkit/CMakeLists.txt +++ b/Code/PgSQL/rdkit/CMakeLists.txt @@ -88,7 +88,7 @@ if(RDK_BUILD_AVALON_SUPPORT) endif(RDK_BUILD_AVALON_SUPPORT) if(RDK_BUILD_INCHI_SUPPORT) set(inchiRegress "inchi") - set(pgRDKitLibList "${pgRDKitLibList}RDInchiLib;Inchi;") + set(pgRDKitLibList "${pgRDKitLibList}RDInchiLib;${INCHI_LIBRARIES};") endif(RDK_BUILD_INCHI_SUPPORT) set(pgRDKitLibList "${pgRDKitLibList}" "MolHash;FMCS;ChemReactions;ChemTransforms;" diff --git a/Code/cmake/Modules/FindInchi.cmake b/Code/cmake/Modules/FindInchi.cmake index 3f1645101..0a24901b5 100644 --- a/Code/cmake/Modules/FindInchi.cmake +++ b/Code/cmake/Modules/FindInchi.cmake @@ -25,3 +25,42 @@ else() set(INCHI_LIBRARIES ${INCHI_LIBRARY} ) mark_as_advanced(INCHI_INCLUDE_DIR INCHI_LIBRARY) endif() +set(CUSTOM_INCHI_PATH "${CMAKE_CURRENT_SOURCE_DIR}/External/INCHI-API") +# check whether we have custom InChI source +if(EXISTS ${CUSTOM_INCHI_PATH}/src/ichican2.c) + message("CUSTOM_INCHI_PATH = ${CUSTOM_INCHI_PATH}") + 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 ${CUSTOM_INCHI_PATH}/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} "${CUSTOM_INCHI_PATH}/${INCHI_BASE}" ${INCHI_MD5SUM}) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf + ${CUSTOM_INCHI_PATH}/INCHI-1-API.zip + WORKING_DIRECTORY ${CUSTOM_INCHI_PATH}) + execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory + "${CUSTOM_INCHI_PATH}/INCHI-1-API/INCHI_API/inchi_dll" "${CUSTOM_INCHI_PATH}/src") + endif(INCHI_FOUND) +endif(EXISTS ${CUSTOM_INCHI_PATH}/src/ichican2.c) +if(EXISTS ${CUSTOM_INCHI_PATH}/src/ichican2.c) + set(INCHI_LIBRARIES Inchi) +endif(EXISTS ${CUSTOM_INCHI_PATH}/src/ichican2.c) +if((NOT EXISTS ${CUSTOM_INCHI_PATH}/src/ichican2.c) + AND (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() diff --git a/External/INCHI-API/CMakeLists.txt b/External/INCHI-API/CMakeLists.txt index c78371c0b..a11984fd3 100644 --- a/External/INCHI-API/CMakeLists.txt +++ b/External/INCHI-API/CMakeLists.txt @@ -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