Skip to content

Commit

Permalink
snap 2
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
  • Loading branch information
audetto committed Apr 29, 2024
1 parent 12c24d0 commit ec43ec6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 6 additions & 4 deletions source/frontends/common2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ target_link_libraries(common2 PRIVATE
windows
)

file(RELATIVE_PATH ROOT_PATH ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
if ("${ROOT_PATH}" STREQUAL "")
file(RELATIVE_PATH RES_REL_FROM_BUILD ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
if ("${RES_REL_FROM_BUILD}" STREQUAL "")
# if the 2 paths are the same
set(ROOT_PATH "./")
set(RES_REL_FROM_BUILD "./")
endif()
file(RELATIVE_PATH SHARE_PATH ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_DATADIR}/applewin)

set(RES_ABS_INSTALL ${CMAKE_INSTALL_FULL_DATADIR}/applewin)
file(RELATIVE_PATH RES_REL_FROM_INSTALL ${CMAKE_INSTALL_FULL_BINDIR} ${RES_ABS_INSTALL})

configure_file(config.h.in config.h)

Expand Down
5 changes: 3 additions & 2 deletions source/frontends/common2/config.h.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// relative path from executable to resources
#cmakedefine ROOT_PATH "@ROOT_PATH@"
#cmakedefine SHARE_PATH "@SHARE_PATH@"
#cmakedefine RES_REL_FROM_BUILD "@RES_REL_FROM_BUILD@"
#cmakedefine RES_ABS_INSTALL "@RES_ABS_INSTALL@"
#cmakedefine RES_REL_FROM_INSTALL "@RES_REL_FROM_INSTALL@"

// this one is a bit of a hack, until resources are embedded in the retro core
#cmakedefine CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@"
11 changes: 7 additions & 4 deletions source/frontends/common2/gnuframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ namespace
const char * path = dirname(self);

// case 1: run from the build folder
paths.emplace_back(std::string(path) + '/'+ ROOT_PATH);
// case 2: run from the installation folder
paths.emplace_back(std::string(path) + '/'+ SHARE_PATH);
paths.emplace_back(std::string(path) + '/'+ RES_REL_FROM_BUILD);
// case 2: relative from the installation folder
paths.emplace_back(std::string(path) + '/'+ RES_REL_FROM_INSTALL);
}

// case 3: use the source folder
// case 3: use absolute install dir
paths.emplace_back(RES_ABS_INSTALL);

// case 4: use the source folder
paths.emplace_back(CMAKE_SOURCE_DIR);

for (const std::string & path : paths)
Expand Down

0 comments on commit ec43ec6

Please sign in to comment.