Skip to content

Commit

Permalink
Set a project-wide variable for molecule data dir AvogadroLibs_SOURCE…
Browse files Browse the repository at this point in the history
…DATA_DIR

Fix OpenChemistry#1615 - use AvogadroLibs_SOURCEDATA_DIR to set the source locations

Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Dec 8, 2024
1 parent 6baaa03 commit b6ed43e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ set(AvogadroLibs_VERSION
find_package(Git)
determine_version(${AvogadroLibs_SOURCE_DIR} ${GIT_EXECUTABLE} "AvogadroLibs")

# path for data / fragment files which could be overriden by package maintainers
# by default we assume we're using the openchemistry superbuild layout
# .. this is used by the fragment library, molecules, crystals, etc.
set(AvogadroLibs_SOURCEDATA_DIR "${AvogadroLibs_SOURCE_DIR}/..")

option(BUILD_SHARED_LIBS "Build with shared libraries" ON)

# Before any plugins are defined, and before any add_subdirectory calls:
Expand Down
14 changes: 7 additions & 7 deletions avogadro/qtplugins/insertfragment/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,41 @@ avogadro_plugin(InsertFragment

# Install the fragments & crystals
# TODO - make this a for loop
set(_molecules "${AvogadroLibs_SOURCE_DIR}/../molecules")
set(_crystals "${AvogadroLibs_SOURCE_DIR}/../crystals")
set(_molecules "${AvogadroLibs_SOURCEDATA_DIR}/molecules")
set(_crystals "${AvogadroLibs_SOURCEDATA_DIR}/crystals")

# Look in parallel directory for the molecule fragment repository
if(NOT EXISTS "${_molecules}")
# download molecules...
ExternalProject_Add(molecules
GIT_REPOSITORY https://github.com/openchemistry/molecules
# or https://github.com/OpenChemistry/molecules/archive/refs/heads/master.zip
SOURCE_DIR "${AvogadroLibs_SOURCE_DIR}/../molecules"
SOURCE_DIR "${AvogadroLibs_SOURCEDATA_DIR}/molecules"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
endif()

install(DIRECTORY "${AvogadroLibs_SOURCE_DIR}/../molecules"
install(DIRECTORY "${AvogadroLibs_SOURCEDATA_DIR}/molecules"
DESTINATION "${INSTALL_DATA_DIR}/avogadro2"
PATTERN ".git" EXCLUDE
)

# crystals
if(NOT EXISTS "${_crystals}")
# download molecules...
# download molecules...
ExternalProject_Add(crystals
GIT_REPOSITORY https://github.com/openchemistry/crystals
# or https://github.com/OpenChemistry/crystals/archive/refs/heads/master.zip
SOURCE_DIR "${AvogadroLibs_SOURCE_DIR}/../crystals"
SOURCE_DIR "${AvogadroLibs_SOURCEDATA_DIR}/crystals"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
endif()

install(DIRECTORY "${AvogadroLibs_SOURCE_DIR}/../crystals"
install(DIRECTORY "${AvogadroLibs_SOURCEDATA_DIR}/crystals"
DESTINATION "${INSTALL_DATA_DIR}/avogadro2"
PATTERN ".git" EXCLUDE
)
6 changes: 3 additions & 3 deletions avogadro/qtplugins/templatetool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ avogadro_plugin(TemplateTool
)

# Install the fragments
set(_fragments "${AvogadroLibs_SOURCE_DIR}/../fragments")
set(_fragments "${AvogadroLibs_SOURCEDATA_DIR}/fragments")

# Look in parallel directory for the molecule fragment repository
if(NOT EXISTS "${_fragments}")
Expand All @@ -33,14 +33,14 @@ ExternalProject_Add(fragments
GIT_REPOSITORY https://github.com/openchemistry/fragments
GIT_TAG main
# or https://github.com/OpenChemistry/molecules/archive/refs/heads/master.zip
SOURCE_DIR "${AvogadroLibs_SOURCE_DIR}/../fragments"
SOURCE_DIR "${AvogadroLibs_SOURCEDATA_DIR}/fragments"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
endif()

install(DIRECTORY "${AvogadroLibs_SOURCE_DIR}/../fragments"
install(DIRECTORY "${AvogadroLibs_SOURCEDATA_DIR}/fragments"
DESTINATION "${INSTALL_DATA_DIR}/avogadro2"
PATTERN ".git" EXCLUDE
)
Expand Down

0 comments on commit b6ed43e

Please sign in to comment.