Yet another variant on how to find data files

This time, the relocation code checks for a "System.c4g" in either
the executable path or a "data" folder directly below. CMake makes
sure that this points somewhere sensible for normal builds.

TODO:
* Check whether this actually works under Unixes. Can "ln -sf"
  delete important stuff? Is there a safe alternative?
* Further unify with the Mac Os solution. Other platforms might
  auto-pack for release builds too, for example - and it might
  be a good idea to have a proper data subdirectory in Mac bundles
  as well.
Peter Wortmann 2011-11-09 00:45:07 +00:00
parent cd93daf8b9
commit d5c075ade8
3 changed files with 21 additions and 13 deletions

View File

@ -1257,6 +1257,18 @@ if (NOT APPLE)
add_custom_target(groups ALL DEPENDS ${OC_C4GROUPS})
endif()
if (NOT APPLE)
# Convert forward spaces to backspaces. "mklink" is very picky with its input
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/planet" CLONK_DATA_DIR)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/data" CLONK_DATA_LINK_DIR)
if (WIN32)
add_custom_command(TARGET clonk POST_BUILD COMMAND "rmdir" "${CLONK_DATA_LINK_DIR}")
add_custom_command(TARGET clonk POST_BUILD COMMAND "mklink" "/J" "${CLONK_DATA_LINK_DIR}" "${CLONK_DATA_DIR}")
else()
add_custom_command(TARGET clonk POST_BUILD COMMAND "ln" "-sf" "${CLONK_DATA_DIR}" "${CLONK_DATA_LINK_DIR}")
endif()
endif()
# Install new files
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/clonk.desktop DESTINATION share/applications)

View File

@ -26,6 +26,8 @@
//========================= Component File Names ============================================
#define C4CFN_DataFolder "data"
#define C4CFN_Engine "Clonk.exe"
#define C4CFN_Material "Material.ocg"

View File

@ -27,19 +27,13 @@ void C4Reloc::Init()
{
Paths.clear();
#ifndef __APPLE__
StdCopyStrBuf planet(Config.General.ExePath);
planet.AppendBackslash();
#ifdef CMAKE_INTDIR
if (!SEqual(CMAKE_INTDIR, "."))
{
planet.Append("..");
planet.AppendBackslash();
}
#endif
planet.Append("planet");
AddPath(planet.getData());
#endif
// Check for system group at EXE path - only add if found
if (FileExists(Config.AtExePath(C4CFN_System)))
AddPath(Config.General.ExePath.getData());
// Or a dedicated data folder directly below
else if (FileExists(Config.AtExePath(C4CFN_DataFolder DirSep C4CFN_System)))
AddPath(Config.AtExePath(C4CFN_DataFolder));
AddPath(Config.General.UserDataPath);
AddPath(Config.General.SystemDataPath);