Skip to content

Commit

Permalink
PACKAGE_PORTABLE will produce a TGZ on Linux and a ZIP on Windows. Fo…
Browse files Browse the repository at this point in the history
…r development we now use PACKAGE_DEV which basically means the portable file layout but no archive generated. For all package types the About dialog will display what package type was used (Portable ZIP, Portable TGZ, Snap, Deb, Nix, or Dev).
  • Loading branch information
bluescan committed Sep 9, 2024
1 parent 17a3cfa commit 21718b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
32 changes: 8 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,22 @@ target_compile_definitions(
$<$<CONFIG:Release>:CONFIG_RELEASE>
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_DEPRECATE>

$<$<BOOL:${PACKAGE_PORTABLE}>:PACKAGE_PORTABLE>
$<$<PLATFORM_ID:Windows>:PLATFORM_WINDOWS>
$<$<PLATFORM_ID:Linux>:PLATFORM_LINUX>

$<$<BOOL:${PACKAGE_PORTABLE}>:PACKAGE_PORTABLE>
$<$<BOOL:${PACKAGE_DEV}>:PACKAGE_DEV>
$<$<AND:$<PLATFORM_ID:Linux>,$<BOOL:${PACKAGE_SNAP}>>:PACKAGE_SNAP>
$<$<AND:$<PLATFORM_ID:Linux>,$<BOOL:${PACKAGE_DEB}>>:PACKAGE_DEB>
$<$<AND:$<PLATFORM_ID:Linux>,$<BOOL:${PACKAGE_NIX}>>:PACKAGE_NIX>

# These shouldn't actually be necessary as there are no direct Windows API calls
# in TacentView (they are abstracted away by the Tacent libraries). But just in case
# anything in the viewer were to call an OS-level function, these enable the UTF-16
# versions if the TACENT_UTF16_API_CALLS option is set.
$<$<AND:$<PLATFORM_ID:Windows>,$<BOOL:${TACENT_UTF16_API_CALLS}>>:UNICODE> # C++ UFF-16
$<$<AND:$<PLATFORM_ID:Windows>,$<BOOL:${TACENT_UTF16_API_CALLS}>>:_UNICODE> # C UTF-16
$<$<AND:$<PLATFORM_ID:Windows>,$<BOOL:${TACENT_UTF16_API_CALLS}>>:TACENT_UTF16_API_CALLS>

$<$<AND:$<PLATFORM_ID:Linux>,$<BOOL:${PACKAGE_SNAP}>>:PACKAGE_SNAP>
$<$<AND:$<PLATFORM_ID:Linux>,$<BOOL:${PACKAGE_DEB}>>:PACKAGE_DEB>
$<$<AND:$<PLATFORM_ID:Linux>,$<BOOL:${PACKAGE_NIX}>>:PACKAGE_NIX>
)

# Set compiler option flags based on specific compiler and configuration.
Expand Down Expand Up @@ -313,29 +314,11 @@ if (CMAKE_SYSTEM_NAME MATCHES Linux)
endif()
"
)
#[[
elseif (PACKAGE_NIX)
install(DIRECTORY Linux/ DESTINATION "${VIEWER_PACKAGE_DIR}")
configure_file("Linux/create_nix.sh.in" "${VIEWER_PACKAGE_DIR}/create_nix.sh" @ONLY)
install(CODE
"
execute_process(COMMAND \"chmod\" \"a+x\" \"ViewerInstall/Package/create_nix.sh\")
execute_process(
COMMAND \"ViewerInstall/Package/create_nix.sh\"
RESULT_VARIABLE package_result
)
if (NOT package_result EQUAL \"0\")
message(FATAL_ERROR \"Viewer -- Nix package creation failed.\")
else()
message(STATUS \"Viewer -- Nix package creation succeeded.\")
endif()
"
)
]]
endif()
endif()

if (CMAKE_SYSTEM_NAME MATCHES Windows)
# The portable package for Windows generates a zip.
if (PACKAGE_PORTABLE)
install(DIRECTORY Windows/ DESTINATION "${VIEWER_PACKAGE_DIR}")
configure_file("Windows/create_zip.ps1.in" "${VIEWER_PACKAGE_DIR}/create_zip.ps1" @ONLY)
Expand All @@ -356,6 +339,7 @@ if (CMAKE_SYSTEM_NAME MATCHES Windows)
endif()

if (CMAKE_SYSTEM_NAME MATCHES Linux)
# The portable package for Linux generates a tgz.
if (PACKAGE_PORTABLE)
install(DIRECTORY Linux/ DESTINATION "${VIEWER_PACKAGE_DIR}")
configure_file("Linux/create_tgz.sh.in" "${VIEWER_PACKAGE_DIR}/create_tgz.sh" @ONLY)
Expand Down
8 changes: 7 additions & 1 deletion Src/Dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ void Viewer::ShowAboutPopup(bool* popen)
package = "Deb";
#elif defined(PACKAGE_NIX)
package = "Nix";
#elif defined(PACKAGE_DEV)
package = "Dev";
#elif defined(PACKAGE_PORTABLE)
package = "Portable";
#if defined(PLATFORM_WINDOWS)
package = "Portable ZIP";
#elif defined(PLATFORM_LINUX)
package = "Portable TGZ";
#endif
#endif

ImGui::Text("Platform: %s", platform.Chr());
Expand Down
4 changes: 2 additions & 2 deletions Src/TacentView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4204,12 +4204,12 @@ int main(int argc, char** argv)
tString configDir; // Directory will be created if needed. Contains the per-user viewer config file.
tString cacheDir; // Directory will be created if needed. Contains cache information that is not required (but can) persist between releases.

#if defined(PLATFORM_WINDOWS) || defined(PACKAGE_PORTABLE)
#if defined(PLATFORM_WINDOWS) || defined(PACKAGE_PORTABLE) || defined(PACKAGE_DEV)
{
// The portable layout is also what should be set while developing -- Everything relative
// to the program executable with separate sub-directories for Assets, Config, and Cache.
// This keeps portable/dev out of the way of any installed packages. Windows currently only
// supports portable.
// supports the portable layout.
tString progDir = tSystem::tGetProgramDir();
assetsDir = progDir + "Assets/";
configDir = progDir + "Config/";
Expand Down

0 comments on commit 21718b1

Please sign in to comment.