Skip to content

Commit

Permalink
CMake: Avoid hard-wired /usr/local/share
Browse files Browse the repository at this point in the history
Instead of defining own CMAKE_INSTALL_SHAREDIR, use existing
CMAKE_INSTALL_FULL_DATADIR.

This way, CMAKE_INSTALL_PREFIX is respected.
  • Loading branch information
gollux committed Aug 15, 2023
1 parent f7fb0a6 commit a86d7ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ include(GNUInstallDirs) # Define GNU standard installation directories
cmake_host_system_information(RESULT OS_NAME QUERY OS_NAME)
message(STATUS "Checking for OS_NAME: ${OS_NAME}")

message(STATUS "set(CMAKE_INSTALL_SHAREDIR /usr/local/share)")
set(CMAKE_INSTALL_SHAREDIR /usr/local/share/)


## Set C build flags
if (NOT MSVC)
Expand Down Expand Up @@ -385,7 +382,7 @@ endif ()
if (WIN32)
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_PREFIX}/config/chips)
else ()
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_SHAREDIR}/${PROJECT_NAME}/chips)
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/chips)
endif ()
add_definitions( -DSTLINK_CHIPS_DIR="${CMAKE_CHIPS_DIR}" )
file(GLOB CHIP_FILES ${CMAKE_SOURCE_DIR}/config/chips/*.chip)
Expand Down
8 changes: 4 additions & 4 deletions src/stlink-gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)

# Install desktop application entry
install(FILES stlink-gui.desktop
DESTINATION ${CMAKE_INSTALL_SHAREDIR}/applications)
DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/applications)

# Install icons
install(FILES icons/stlink-gui.svg
DESTINATION ${CMAKE_INSTALL_SHAREDIR}/icons/hicolor/scalable/apps)
DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor/scalable/apps)

set(GUI_SOURCES gui.c gui.h)

## stlink-gui
add_executable(stlink-gui ${GUI_SOURCES})
install(FILES stlink-gui.ui DESTINATION ${CMAKE_INSTALL_SHAREDIR}/${PROJECT_NAME})
install(FILES stlink-gui.ui DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME})
set_target_properties(stlink-gui PROPERTIES
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_SHAREDIR}/${PROJECT_NAME}")
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}")
target_link_libraries(stlink-gui ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS})
install(TARGETS stlink-gui DESTINATION ${CMAKE_BINDIR})
endif ()
Expand Down

0 comments on commit a86d7ca

Please sign in to comment.