File: FindInchi.cmake

package info (click to toggle)
rdkit 202503.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 220,160 kB
  • sloc: cpp: 399,240; python: 77,453; ansic: 25,517; java: 8,173; javascript: 4,005; sql: 2,389; yacc: 1,565; lex: 1,263; cs: 1,081; makefile: 580; xml: 229; fortran: 183; sh: 105
file content (66 lines) | stat: -rw-r--r-- 3,055 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# - Try to find Inchi lib
# Once done this will define
#
#  INCHI_FOUND - system has inchi lib
#  INCHI_INCLUDE_DIR - the inchi include directory
#  INCHI_LIBRARIES - the inchi library

# Taken from the open babel distribution
#  https://openbabel.svn.sourceforge.net/svnroot/openbabel/openbabel/trunk/cmake/modules/FindInchi.cmake
# Copyright (c) 2010 Marcus D. Hanwell, <marcus@cryos.org>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

if(INCHI_INCLUDE_DIR AND INCHI_LIBRARY)
  # in cache already
  set(INCHI_FOUND TRUE)
else()
  find_path(INCHI_INCLUDE_DIR NAMES inchi_api.h PATHS /usr/include/inchi )
  find_library(INCHI_LIBRARY NAMES inchi Inchi)
  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(Inchi
	  "Could NOT find InChI in system locations" INCHI_LIBRARY
	  INCHI_INCLUDE_DIR)
  set(INCHI_INCLUDE_DIRS ${INCHI_INCLUDE_DIR} )
  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/INCHI_BASE/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/INCHI_BASE/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 "https://github.com/IUPAC-InChI/InChI/releases/download/v1.07.3/INCHI-1-SRC.zip")
    endif()
    if(NOT DEFINED INCHI_MD5SUM)
      set(INCHI_MD5SUM "b761f37a7d3a3ff8574daf6906993759")
    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-SRC.zip
      WORKING_DIRECTORY ${CUSTOM_INCHI_PATH})
    execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory
        "${CUSTOM_INCHI_PATH}/INCHI-1-SRC" "${CUSTOM_INCHI_PATH}/src")
  endif(INCHI_FOUND)
endif(EXISTS ${CUSTOM_INCHI_PATH}/src/INCHI_BASE/src/ichican2.c)
if(EXISTS ${CUSTOM_INCHI_PATH}/src/INCHI_BASE/src/ichican2.c)
  set(INCHI_LIBRARIES Inchi)
endif(EXISTS ${CUSTOM_INCHI_PATH}/src/INCHI_BASE/src/ichican2.c)
if((NOT EXISTS ${CUSTOM_INCHI_PATH}/src/INCHI_BASE/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()