Skip to content

Commit

Permalink
Merge pull request #1851 from ghutchis/set-default-fragment-dir
Browse files Browse the repository at this point in the history
Set a project-wide variable for molecule data dir AvogadroLibs_SOURCE…
  • Loading branch information
ghutchis authored Dec 8, 2024
2 parents 05d7e5c + b6ed43e commit 2d772c3
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 2d772c3

Please sign in to comment.