diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8739964e5..c27ab3d49 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,9 +102,9 @@ set(SHAREDIR ${DATADIR})
# BUILD_OWNCLOUD_OSX_BUNDLE was not initialized OR set to true on OSX
if(APPLE AND (NOT DEFINED BUILD_OWNCLOUD_OSX_BUNDLE OR BUILD_OWNCLOUD_OSX_BUNDLE))
set(BUILD_OWNCLOUD_OSX_BUNDLE ON)
- set(OWNCLOUD_OSX_BUNDLE "${APPLICATION_EXECUTABLE}.app")
- set(LIB_INSTALL_DIR "${APPLICATION_EXECUTABLE}.app/Contents/MacOS")
- set(BIN_INSTALL_DIR "${APPLICATION_EXECUTABLE}.app/Contents/MacOS")
+ set(OWNCLOUD_OSX_BUNDLE "${APPLICATION_NAME}.app")
+ set(LIB_INSTALL_DIR "${APPLICATION_NAME}.app/Contents/MacOS")
+ set(BIN_INSTALL_DIR "${APPLICATION_NAME}.app/Contents/MacOS")
# BUILD_OWNCLOUD_OSX_BUNDLE was disabled on OSX
elseif(APPLE AND NOT BUILD_OWNCLOUD_OSX_BUNDLE)
diff --git a/admin/osx/macosx.pkgproj.cmake b/admin/osx/macosx.pkgproj.cmake
index 0552e1c32..50d338310 100644
--- a/admin/osx/macosx.pkgproj.cmake
+++ b/admin/osx/macosx.pkgproj.cmake
@@ -22,7 +22,7 @@
GID
80
PATH
- @APPLICATION_EXECUTABLE@.app
+ @APPLICATION_NAME@.app
PATH_TYPE
3
PERMISSIONS
diff --git a/cmake/modules/MacOSXBundleInfo.plist.in b/cmake/modules/MacOSXBundleInfo.plist.in
index 04855b813..66c743374 100644
--- a/cmake/modules/MacOSXBundleInfo.plist.in
+++ b/cmake/modules/MacOSXBundleInfo.plist.in
@@ -9,7 +9,7 @@
CFBundleDevelopmentRegion
English
CFBundleExecutable
- @APPLICATION_EXECUTABLE@
+ @APPLICATION_NAME@
CFBundleIconFile
@APPLICATION_ICON_NAME@.icns
CFBundleIdentifier
diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt
index cea206600..81c2460e0 100644
--- a/src/cmd/CMakeLists.txt
+++ b/src/cmd/CMakeLists.txt
@@ -27,24 +27,20 @@ if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
endif()
if(NOT BUILD_LIBRARIES_ONLY)
- add_executable(${cmd_NAME} cmd.cpp)
+ add_executable(${cmd_NAME} cmd.cpp)
+
+ if(BUILD_OWNCLOUD_OSX_BUNDLE)
set_target_properties(${cmd_NAME} PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY} )
+ RUNTIME_OUTPUT_DIRECTORY "${BIN_OUTPUT_DIRECTORY}/${OWNCLOUD_OSX_BUNDLE}/Contents/MacOS")
+ else()
+ set_target_properties(${cmd_NAME} PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY})
- target_link_libraries(${cmd_NAME} cmdCore)
-endif()
-
-# OSX: Copy nextcloudcmd to app bundle, src/gui will run macdeployqt
-if(BUILD_OWNCLOUD_OSX_BUNDLE)
- add_custom_command(TARGET ${cmd_NAME} POST_BUILD
- COMMAND "cp"
- "$"
- "${BIN_OUTPUT_DIRECTORY}/${OWNCLOUD_OSX_BUNDLE}/Contents/MacOS"
- COMMENT "Copying nextcloudcmd..."
- )
-elseif(NOT BUILD_LIBRARIES_ONLY)
install(TARGETS ${cmd_NAME}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
+
+ target_link_libraries(${cmd_NAME} cmdCore)
endif()
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 284e71752..fb87145f8 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -375,6 +375,11 @@ else()
# we must add MACOSX_BUNDLE only if building a bundle
add_executable(${APPLICATION_EXECUTABLE} WIN32 MACOSX_BUNDLE main.cpp ${APP_ICON})
+ if (BUILD_OWNCLOUD_OSX_BUNDLE)
+ set_target_properties(${APPLICATION_EXECUTABLE} PROPERTIES
+ OUTPUT_NAME "${APPLICATION_NAME}")
+ endif()
+
set (QM_DIR ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/Translations)
install(FILES ${client_I18N} DESTINATION ${QM_DIR})
get_target_property(_qmake Qt5::qmake LOCATION)