Skip to content

Commit

Permalink
Updated install script
Browse files Browse the repository at this point in the history
Do not install Enigma.db database everytime to not overwrite user data
  • Loading branch information
baderouaich committed Jul 15, 2024
1 parent 57c2c00 commit ea160e5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-windows-mingw-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Generate Project Makefiles
run: |
md build && cd build
cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DENIGMA_ENABLE_TESTS=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
cmake .. -G"Unix Makefiles" -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_BUILD_TYPE=Release -DENIGMA_ENABLE_TESTS=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
- name: Build Enigma Tests
run: cd build && make EnigmaTests -j%NUMBER_OF_PROCESSORS%
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-windows-mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Generate Project Makefiles
run: |
md build && cd build
cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DENIGMA_ENABLE_TESTS=OFF -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
cmake .. -G"Unix Makefiles" -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_BUILD_TYPE=Release -DENIGMA_ENABLE_TESTS=OFF -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
- name: Build Enigma
run: cd build && make -j%NUMBER_OF_PROCESSORS%
Expand Down
13 changes: 0 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ option(ENIGMA_ENABLE_TESTS "Enable/Disable building of tests" OFF)
option(ENIGMA_BUILD_DOCS "Build Doxygen API documentation" OFF)
#####################################################

################# Force x64 arch ###########################
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# No need to add compile options for Visual Studio, it's handled by the generator platform
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(CMAKE_GENERATOR_PLATFORM "x64" CACHE STRING "" FORCE)
else()
add_compile_options(/machine:x64)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_compile_options(-m64)
endif()
#####################################################

###### Doxygen Documentation ######
if (ENIGMA_BUILD_DOCS)
message(STATUS "Building Doxygen docs is enabled")
Expand Down
36 changes: 26 additions & 10 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,46 @@
include(GNUInstallDirs)

# Determine the installation directories
if(WIN32)
if (WIN32)
set(INSTALL_BASE_DIR "$ENV{ProgramFiles}/Enigma")
else()
else ()
# Get the user's home directory
if(NOT DEFINED ENV{HOME})
if (NOT DEFINED ENV{HOME})
message(FATAL_ERROR "The HOME environment variable is not defined.")
endif()
endif ()
set(USER_DOT_LOCAL_DIR "$ENV{HOME}/.local")
set(INSTALL_BASE_DIR "$ENV{HOME}/Enigma")
endif()
endif ()

# Install the executable to /home/$(whoami)/Enigma/Enigma
install(TARGETS Enigma RUNTIME DESTINATION ${INSTALL_BASE_DIR})

# Install res files to /home/$(whoami)/Enigma/res
#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/
# DESTINATION ${INSTALL_BASE_DIR}/res
# FILES_MATCHING PATTERN "*")

# Install other resource files
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/
DESTINATION ${INSTALL_BASE_DIR}/res
FILES_MATCHING PATTERN "*")
FILES_MATCHING PATTERN "*"
PATTERN "Enigma.db" EXCLUDE) # Exclude Enigma.db database from this install command,
# we don't want to overwrite user's data on an update
# Check if Enigma.db exists and install it if it doesn't
install(CODE "
if(NOT EXISTS \"${INSTALL_BASE_DIR}/res/database/Enigma.db\")
message(STATUS \"Enigma.db is missing. Installing it from repository's resources...\")
file(COPY \"${CMAKE_CURRENT_SOURCE_DIR}/res/database/Enigma.db\" DESTINATION \"${INSTALL_BASE_DIR}/res/database\")
else()
message(STATUS \"Enigma.db already exists. Skipping.\")
endif()
")

# Install .desktop file to /home/$(whoami)/Enigma/Enigma.desktop
if(UNIX AND NOT APPLE)
# Create the .desktop file content
if (UNIX AND NOT APPLE)
# Create the .desktop file content
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/Enigma.desktop"
"[Desktop Entry]
"[Desktop Entry]
Type=Application
Name=${PROJECT_NAME}
Version=${PROJECT_VERSION}
Expand All @@ -56,4 +72,4 @@ Terminal=false"

elseif (WIN32)
# TODO create a shortcut of the app in windows
endif()
endif ()

0 comments on commit ea160e5

Please sign in to comment.