diff --git a/panda/src/configfiles/CMakeLists.txt b/panda/src/configfiles/CMakeLists.txt index 69509806f9..fe1e642589 100644 --- a/panda/src/configfiles/CMakeLists.txt +++ b/panda/src/configfiles/CMakeLists.txt @@ -32,19 +32,43 @@ else() "$XDG_CACHE_HOME/panda3d") endif() -configure_file(panda.prc.in "${CMAKE_BINARY_DIR}/etc/20_panda.prc") if(IS_MULTICONFIG) - file(GENERATE OUTPUT "${PROJECT_BINARY_DIR}/$/etc/20_panda.prc" - INPUT "${PROJECT_BINARY_DIR}/etc/20_panda.prc") + set(_out_path "${PROJECT_BINARY_DIR}/$/etc") +else() + set(_out_path "${PROJECT_BINARY_DIR}/etc") endif() if(WIN32) set(_confdir "etc") - else() # On Unices, ask the GNUInstallDirs module where /etc is set(_confdir "${CMAKE_INSTALL_FULL_SYSCONFDIR}") - endif() -install(FILES "${CMAKE_BINARY_DIR}/etc/20_panda.prc" COMPONENT Core DESTINATION ${_confdir}) +# Path from the directory containing *.prc to the *parent of* models/ +# In the build tree, reckoning this is pretty easy +set(MODELS_PARENT_PATH "..") +configure_file(panda.prc.in "${CMAKE_CURRENT_BINARY_DIR}/20_panda.prc") + +# For the install tree, we need to introspect our paths +if(_confdir MATCHES "^/") + set(_abs_confdir "${_confdir}") +else() + set(_abs_confdir "${CMAKE_INSTALL_PREFIX}/${_confdir}") +endif() +if(CMAKE_INSTALL_DATADIR MATCHES "^/") + set(_abs_datadir "${CMAKE_INSTALL_DATADIR}") +else() + set(_abs_datadir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}") +endif() +file(RELATIVE_PATH MODELS_PARENT_PATH + "${_abs_confdir}" "${_abs_datadir}/panda3d") +configure_file(panda.prc.in "${CMAKE_CURRENT_BINARY_DIR}/20_panda.prc.install") + +file(GENERATE OUTPUT "${_out_path}/20_panda.prc" + INPUT "${CMAKE_CURRENT_BINARY_DIR}/20_panda.prc") +file(GENERATE OUTPUT "${_out_path}/20_panda.prc.install" + INPUT "${CMAKE_CURRENT_BINARY_DIR}/20_panda.prc.install") + +install(FILES "${_out_path}/20_panda.prc.install" RENAME "20_panda.prc" + COMPONENT Core DESTINATION ${_confdir}) diff --git a/panda/src/configfiles/panda.prc.in b/panda/src/configfiles/panda.prc.in index 373852b241..a1f3fd8b47 100644 --- a/panda/src/configfiles/panda.prc.in +++ b/panda/src/configfiles/panda.prc.in @@ -3,10 +3,12 @@ # Some paths first... plugin-path $THIS_PRC_DIR/../lib -model-path $THIS_PRC_DIR/../share/panda3d/models +model-path $MAIN_DIR +model-path $THIS_PRC_DIR/${MODELS_PARENT_PATH} +model-path $THIS_PRC_DIR/${MODELS_PARENT_PATH}/models # Let's set up a default window size of 800x600. The user can -# override this in his or her personal prc file. +# override this in a separate, personal prc file. win-origin -2 -2 win-size 800 600