From b6ed43e18f4e561eea8fec21fa3e0e75962d1f3a Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Sun, 8 Dec 2024 00:41:43 -0500 Subject: [PATCH] Set a project-wide variable for molecule data dir AvogadroLibs_SOURCEDATA_DIR Fix #1615 - use AvogadroLibs_SOURCEDATA_DIR to set the source locations Signed-off-by: Geoff Hutchison --- CMakeLists.txt | 5 +++++ avogadro/qtplugins/insertfragment/CMakeLists.txt | 14 +++++++------- avogadro/qtplugins/templatetool/CMakeLists.txt | 6 +++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb15770e8b..0008bafc38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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: diff --git a/avogadro/qtplugins/insertfragment/CMakeLists.txt b/avogadro/qtplugins/insertfragment/CMakeLists.txt index 3484257ca9..4f4f3f0e41 100644 --- a/avogadro/qtplugins/insertfragment/CMakeLists.txt +++ b/avogadro/qtplugins/insertfragment/CMakeLists.txt @@ -10,8 +10,8 @@ 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}") @@ -19,32 +19,32 @@ if(NOT EXISTS "${_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 ) diff --git a/avogadro/qtplugins/templatetool/CMakeLists.txt b/avogadro/qtplugins/templatetool/CMakeLists.txt index 3f68e6dd79..220108458f 100644 --- a/avogadro/qtplugins/templatetool/CMakeLists.txt +++ b/avogadro/qtplugins/templatetool/CMakeLists.txt @@ -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}") @@ -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 )