From bb168b2a893c4da1e21b4100fc477c0f400fe190 Mon Sep 17 00:00:00 2001
From: Paolo Tosco <paolo.tosco.mail@gmail.com>
Date: Fri, 5 Aug 2016 12:21:01 +0100
Subject: [PATCH 1/2] - this should fix the problem with "Inchi" being
hardcoded into PostgreSQL
---
CMakeLists.txt | 41 +++++++++++++++++++++++++++++++++++
Code/PgSQL/rdkit/CMakeLists.txt | 2 +-
External/INCHI-API/CMakeLists.txt | 45 +++------------------------------------
3 files changed, 45 insertions(+), 43 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1a2e18f..3ecedea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -127,6 +127,47 @@ if(MSVC)
ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB")
endif(MSVC)
+if(RDK_BUILD_INCHI_SUPPORT)
+ # search system InChI
+ find_package(Inchi)
+ 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(STATUS "Found InChI software locally")
+ set(INCHI_LIBRARIES Inchi)
+ 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((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()
+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 d717185..2e5b465 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/External/INCHI-API/CMakeLists.txt b/External/INCHI-API/CMakeLists.txt
index c78371c..a4ec8f7 100644
--- a/External/INCHI-API/CMakeLists.txt
+++ b/External/INCHI-API/CMakeLists.txt
@@ -1,37 +1,6 @@
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
@@ -54,17 +23,9 @@ if(RDK_BUILD_INCHI_SUPPORT)
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()
-
+ install(TARGETS Inchi DESTINATION ${RDKit_LibDir})
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
+ endif()
endif(RDK_BUILD_INCHI_SUPPORT)
# check whether InChI support is ON after the search
From 6ed79ec3483a2813f2e0c6f6928bc9c33c5ace61 Mon Sep 17 00:00:00 2001
From: Paolo Tosco <paolo.tosco.mail@gmail.com>
Date: Fri, 5 Aug 2016 17:18:45 +0100
Subject: [PATCH 2/2] - moved the InChI check code out of the main
CMakeLists.txt into FindInchi.cmake
---
CMakeLists.txt | 37 -------------------
Code/cmake/Modules/FindInchi.cmake | 39 ++++++++++++++++++++
External/INCHI-API/CMakeLists.txt | 75 ++++++++++++++++++--------------------
3 files changed, 75 insertions(+), 76 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ecedea..a53e964 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -128,44 +128,7 @@ if(MSVC)
endif(MSVC)
if(RDK_BUILD_INCHI_SUPPORT)
- # search system InChI
find_package(Inchi)
- 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(STATUS "Found InChI software locally")
- set(INCHI_LIBRARIES Inchi)
- 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((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()
endif(RDK_BUILD_INCHI_SUPPORT)
if(RDK_BUILD_PYTHON_WRAPPERS)
diff --git a/Code/cmake/Modules/FindInchi.cmake b/Code/cmake/Modules/FindInchi.cmake
index 3f16451..0a24901 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 a4ec8f7..a11984f 100644
--- a/External/INCHI-API/CMakeLists.txt
+++ b/External/INCHI-API/CMakeLists.txt
@@ -1,53 +1,50 @@
add_custom_target(inchi_support ALL)
-if(RDK_BUILD_INCHI_SUPPORT)
- 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})
- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
- 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