diff --git a/AI/BattleAI/CMakeLists.txt b/AI/BattleAI/CMakeLists.txt index 938efa76a..096d10b0c 100644 --- a/AI/BattleAI/CMakeLists.txt +++ b/AI/BattleAI/CMakeLists.txt @@ -39,7 +39,4 @@ vcmi_set_output_dir(BattleAI "AI") set_target_properties(BattleAI PROPERTIES ${PCH_PROPERTIES}) cotire(BattleAI) -if(NOT APPLE) # Already inside vcmiclient bundle - install(TARGETS BattleAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) -endif() - +install(TARGETS BattleAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) diff --git a/AI/EmptyAI/CMakeLists.txt b/AI/EmptyAI/CMakeLists.txt index 164884b75..dc3d8c08d 100644 --- a/AI/EmptyAI/CMakeLists.txt +++ b/AI/EmptyAI/CMakeLists.txt @@ -22,6 +22,4 @@ vcmi_set_output_dir(EmptyAI "AI") set_target_properties(EmptyAI PROPERTIES ${PCH_PROPERTIES}) -if(NOT APPLE) # Already inside vcmiclient bundle - install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) -endif(NOT APPLE) +install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) diff --git a/AI/StupidAI/CMakeLists.txt b/AI/StupidAI/CMakeLists.txt index f99f33b78..cb083c425 100644 --- a/AI/StupidAI/CMakeLists.txt +++ b/AI/StupidAI/CMakeLists.txt @@ -23,7 +23,4 @@ vcmi_set_output_dir(StupidAI "AI") set_target_properties(StupidAI PROPERTIES ${PCH_PROPERTIES}) cotire(StupidAI) -if(NOT APPLE) # Already inside vcmiclient bundle - install(TARGETS StupidAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) -endif() - +install(TARGETS StupidAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) diff --git a/AI/VCAI/CMakeLists.txt b/AI/VCAI/CMakeLists.txt index c107e5a72..d49a96375 100644 --- a/AI/VCAI/CMakeLists.txt +++ b/AI/VCAI/CMakeLists.txt @@ -31,7 +31,7 @@ if(ANDROID) # android compiles ai libs into main lib directly, so we skip this l endif() add_library(VCAI SHARED ${VCAI_SRCS} ${VCAI_HEADERS}) -if (FL_FOUND) +if(FL_FOUND) target_link_libraries(VCAI ${FL_LIBRARIES} vcmi) else() target_link_libraries(VCAI fl-static vcmi) @@ -42,6 +42,4 @@ vcmi_set_output_dir(VCAI "AI") set_target_properties(VCAI PROPERTIES ${PCH_PROPERTIES}) cotire(VCAI) -if(NOT APPLE) # Already inside vcmiclient bundle - install(TARGETS VCAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) -endif() +install(TARGETS VCAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29a2a9dbe..e347ade6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,15 @@ project(VCMI) +# TODO +# - macOS: there is problem with running fixup_bundle in main project after subdirectories. +# Cmake put them after all install code of main CMakelists in cmake_install.cmake +# Currently I just added extra add_subdirectory and CMakeLists.txt in osx directory to bypass that. +# - macOS: fix install with built-in minizip +# - macOS: try to fix build with RPATH. +# Currently if CMAKE_MACOSX_RPATH=1 then AI libs unable to find @rpath/libvcmi.dylib +# I tried to set few different INSTALL_RPATH for all targets in AI directory, but nothing worked. +# - build: cleanup remove_directory copy_directory mess. +# When I was trying to fix it copy_if_different failed to work for me. +# - build: and find a way to move add_custom_command for assets deploy out of "lib/CMakeLists.txt" if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING @@ -6,7 +17,6 @@ if(NOT CMAKE_BUILD_TYPE) FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo) endif() -set(CMAKE_MACOSX_RPATH 1) set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules) include(VCMIUtils) @@ -20,6 +30,9 @@ option(ENABLE_LAUNCHER "Enable compilation of launcher" ON) option(ENABLE_TEST "Enable compilation of unit tests" ON) option(ENABLE_PCH "Enable compilation using precompiled headers" ON) +# Useful for debugging +option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF) + # Allow to pass package name from Travis CI set(PACKAGE_NAME_SUFFIX "" CACHE STRING "Suffix for CPack package name") set(PACKAGE_FILE_NAME "" CACHE STRING "Override for CPack package filename") @@ -37,6 +50,11 @@ else() cmake_minimum_required(VERSION 2.6) endif() +# Find better place for this +if(APPLE) + set(CMAKE_MACOSX_RPATH 0) +endif() + ############################################ # Documentation section # ############################################ @@ -84,7 +102,7 @@ if(WIN32) endif(WIN32) if(NOT WIN32) - INCLUDE(CheckLibraryExists) + include(CheckLibraryExists) #check if some platform-specific libraries are needed for linking CHECK_LIBRARY_EXISTS(rt shm_open "" HAVE_RT_LIB) @@ -147,37 +165,51 @@ elseif(APPLE) # includes lib path which determines where to install shared libraries (either /lib or /lib64) include(GNUInstallDirs) - set(BIN_DIR "." CACHE STRING "Where to install binaries") - set(LIB_DIR "." CACHE STRING "Where to install main library") - set(DATA_DIR "../h3" CACHE STRING "Where to install data files") + if(ENABLE_MONOLITHIC_INSTALL) + set(BIN_DIR "." CACHE STRING "Where to install binaries") + set(LIB_DIR "." CACHE STRING "Where to install main library") + set(DATA_DIR "." CACHE STRING "Where to install data files") + else() + set(APP_BUNDLE_DIR "${CMAKE_PROJECT_NAME}.app") + set(APP_BUNDLE_CONTENTS_DIR "${APP_BUNDLE_DIR}/Contents") + set(APP_BUNDLE_BINARY_DIR "${APP_BUNDLE_CONTENTS_DIR}/MacOS") + set(APP_BUNDLE_RESOURCES_DIR "${APP_BUNDLE_CONTENTS_DIR}/Resources") + + set(BIN_DIR "${APP_BUNDLE_BINARY_DIR}" CACHE STRING "Where to install binaries") + set(LIB_DIR "${APP_BUNDLE_BINARY_DIR}" CACHE STRING "Where to install main library") + set(DATA_DIR "${APP_BUNDLE_RESOURCES_DIR}/Data" CACHE STRING "Where to install data files") + endif() else() # includes lib path which determines where to install shared libraries (either /lib or /lib64) include(GNUInstallDirs) - if(NOT BIN_DIR) - set(BIN_DIR "bin" CACHE STRING "Where to install binaries") - endif() - if(NOT LIB_DIR) - set(LIB_DIR "${CMAKE_INSTALL_LIBDIR}/vcmi" CACHE STRING "Where to install main library") - endif() - if(NOT DATA_DIR) - set(DATA_DIR "share/vcmi" CACHE STRING "Where to install data files") + if(ENABLE_MONOLITHIC_INSTALL) + set(BIN_DIR "." CACHE STRING "Where to install binaries") + set(LIB_DIR "." CACHE STRING "Where to install main library") + set(DATA_DIR "." CACHE STRING "Where to install data files") + else() + if(NOT BIN_DIR) + set(BIN_DIR "bin" CACHE STRING "Where to install binaries") + endif() + if(NOT LIB_DIR) + set(LIB_DIR "${CMAKE_INSTALL_LIBDIR}/vcmi" CACHE STRING "Where to install main library") + endif() + if(NOT DATA_DIR) + set(DATA_DIR "share/vcmi" CACHE STRING "Where to install data files") + endif() endif() endif() -set (AI_LIB_DIR "${LIB_DIR}/AI") -set (SCRIPTING_LIB_DIR "${LIB_DIR}/scripting") +set(AI_LIB_DIR "${LIB_DIR}/AI") +set(SCRIPTING_LIB_DIR "${LIB_DIR}/scripting") #define required constants add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_DIR}") add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/${BIN_DIR}") add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/${LIB_DIR}") -SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/vcmi") -SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - # precompiled header configuration -SET(PCH_PROPERTIES +set(PCH_PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER ${ENABLE_PCH} COTIRE_ADD_UNITY_BUILD FALSE COTIRE_CXX_PREFIX_HEADER_INIT "StdInc.h" @@ -202,36 +234,18 @@ if(ENABLE_TEST) endif() ####################################### -# Installation section # +# Installation section # ####################################### -# For apple these files will be already inside vcmiclient bundle -if(NOT APPLE) - # copy whole directory but .svn control files - install(DIRECTORY config DESTINATION ${DATA_DIR}) - # copy vcmi mod along with all its content - install(DIRECTORY Mods/vcmi DESTINATION ${DATA_DIR}/Mods) +install(DIRECTORY config DESTINATION ${DATA_DIR}) +install(DIRECTORY Mods DESTINATION ${DATA_DIR}) - # that script is useless for Windows - if(NOT WIN32) - install(FILES vcmibuilder DESTINATION ${BIN_DIR} PERMISSIONS - OWNER_WRITE OWNER_READ OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE) - endif() -endif() - -if(NOT WIN32 AND NOT APPLE) - #install icons and desktop file on Linux - #FIXME: move to client makefile? - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.64x64.png" DESTINATION share/icons/hicolor/64x64/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.48x48.png" DESTINATION share/icons/hicolor/48x48/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.32x32.png" DESTINATION share/icons/hicolor/32x32/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.256x256.png" DESTINATION share/icons/hicolor/256x256/apps RENAME vcmiclient.png) - install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.desktop" DESTINATION share/applications) - if(ENABLE_LAUNCHER) #FIXME: move to launcher makefile? - install(FILES "${CMAKE_SOURCE_DIR}/launcher/vcmilauncher.desktop" DESTINATION share/applications) - endif() +# that script is useless for Windows +if(NOT WIN32) + install(FILES vcmibuilder DESTINATION ${BIN_DIR} PERMISSIONS + OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) endif() ####################################### @@ -248,12 +262,6 @@ set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSIO set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0) -INSTALL(CODE " -set(BU_CHMOD_BUNDLE_ITEMS ON) -include(BundleUtilities) -fixup_bundle(\"${APP_BUNDLE_DIR}\" \"\" \"\") -" COMPONENT Runtime) - if("${PACKAGE_NAME_SUFFIX}" STREQUAL "") set(CPACK_PACKAGE_NAME "VCMI") else() @@ -277,17 +285,23 @@ if(WIN32) set(CPACK_NSIS_PACKAGE_NAME "VCMI ${CPACK_PACKAGE_VERSION} ${PACKAGE_NAME_SUFFIX} ") endif() set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES") - set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " CreateShortCut \\\"$DESKTOP\\\\VCMI.lnk\\\" \\\"$INSTDIR\\\\VCMI_launcher.exe\\\"") - set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " Delete \\\"$DESKTOP\\\\VCMI.lnk\\\" ") + if(ENABLE_LAUNCHER) + set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " CreateShortCut \\\"$DESKTOP\\\\VCMI.lnk\\\" \\\"$INSTDIR\\\\VCMI_launcher.exe\\\"") + else() + set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " CreateShortCut \\\"$DESKTOP\\\\VCMI.lnk\\\" \\\"$INSTDIR\\\\VCMI_client.exe\\\"") + endif() + set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " Delete \\\"$DESKTOP\\\\VCMI.lnk\\\" ") configure_file("${CMAKE_SOURCE_DIR}/cmake_modules/CMakeCPackOptions.cmake.in" "${CMAKE_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY) set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CMakeCPackOptions.cmake") -elseif(APPLE) +elseif(APPLE AND NOT ENABLE_MONOLITHIC_INSTALL) set(CPACK_MONOLITHIC_INSTALL 1) set(CPACK_GENERATOR "DragNDrop") set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/osx/dmg_background.png") set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/osx/dmg_DS_Store") + set(MACOSX_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") + set(MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") if(ENABLE_LAUNCHER) set(MACOSX_BUNDLE_EXECUTABLE_NAME "vcmilauncher") else() @@ -295,31 +309,13 @@ elseif(APPLE) endif() set(MACOSX_BUNDLE_ICON_FILE "vcmi.icns") - install(DIRECTORY ${CMAKE_SOURCE_DIR}/config/ DESTINATION ${APP_BUNDLE_CONTENTS_DIR}/Data/config/) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/Mods/vcmi/ DESTINATION ${APP_BUNDLE_CONTENTS_DIR}/Data/Mods/vcmi/) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/launcher/icons/ DESTINATION ${APP_BUNDLE_CONTENTS_DIR}/Data/launcher/icons/) + install(FILES "${CMAKE_SOURCE_DIR}/osx/vcmi.icns" DESTINATION ${APP_BUNDLE_RESOURCES_DIR}) - install(FILES ${CMAKE_SOURCE_DIR}/osx/vcmi.icns DESTINATION ${APP_BUNDLE_RESOURCES_DIR}) + configure_file("${CMAKE_SOURCE_DIR}/osx/Info.plist.in" "${CMAKE_BINARY_DIR}/Info.plist") + install(FILES "${CMAKE_BINARY_DIR}/Info.plist" DESTINATION ${APP_BUNDLE_CONTENTS_DIR}) - configure_file(${CMAKE_SOURCE_DIR}/osx/Info.plist.in - "${APP_BUNDLE_CONTENTS_DIR}/Info.plist") - - if(ENABLE_LAUNCHER) - find_program(TOOL_MACDEPLOYQT NAMES macdeployqt PATHS ${qt_base_dir}/bin) - if(NOT TOOL_MACDEPLOYQT) - message(FATAL_ERROR "Could not find macdeployqt") - endif() - string(REPLACE " " "\\ " ESCAPED_BUNDLE_DIR ${APP_BUNDLE_DIR}) - install(CODE "execute_process(COMMAND ${TOOL_MACDEPLOYQT} ${ESCAPED_BUNDLE_DIR} -verbose=2)") - endif() - - INSTALL(CODE " - set(BU_CHMOD_BUNDLE_ITEMS ON) - include(BundleUtilities) - fixup_bundle(\"${APP_BUNDLE_DIR}\" \"\" \"\") - " COMPONENT Runtime) - - install(DIRECTORY ${APP_BUNDLE_DIR} DESTINATION "." USE_SOURCE_PERMISSIONS) + # Bundle fixing code must be in separate directory to be executed after all other install code + add_subdirectory(osx) else() set(CPACK_GENERATOR TGZ) endif() @@ -328,4 +324,4 @@ include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC GIT_SHA1) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Version.cpp.in" "${CMAKE_BINARY_DIR}/Version.cpp" @ONLY) -INCLUDE(CPack) +include(CPack) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 3396ecbe2..efac19004 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -143,6 +143,14 @@ vcmi_set_output_dir(vcmiclient "") set_target_properties(vcmiclient PROPERTIES ${PCH_PROPERTIES}) cotire(vcmiclient) -if(NOT APPLE) # Already inside vcmiclient bundle - install(TARGETS vcmiclient DESTINATION ${BIN_DIR}) -endif(NOT APPLE) +install(TARGETS vcmiclient DESTINATION ${BIN_DIR}) + +#install icons and desktop file on Linux +if(NOT WIN32 AND NOT APPLE) + #FIXME: move to client makefile? + install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.64x64.png" DESTINATION share/icons/hicolor/64x64/apps RENAME vcmiclient.png) + install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.48x48.png" DESTINATION share/icons/hicolor/48x48/apps RENAME vcmiclient.png) + install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.32x32.png" DESTINATION share/icons/hicolor/32x32/apps RENAME vcmiclient.png) + install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.256x256.png" DESTINATION share/icons/hicolor/256x256/apps RENAME vcmiclient.png) + install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.desktop" DESTINATION share/applications) +endif() diff --git a/cmake_modules/VCMIUtils.cmake b/cmake_modules/VCMIUtils.cmake index d7d8dc802..a37469f13 100644 --- a/cmake_modules/VCMIUtils.cmake +++ b/cmake_modules/VCMIUtils.cmake @@ -1,19 +1,9 @@ ####################################### -# Output directories # +# Build output directories # ####################################### -if(APPLE) - set(MACOSX_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") - set(MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") - set(APP_BUNDLE_NAME "${CMAKE_PROJECT_NAME}.app") - set(APP_BUNDLE_DIR "${CMAKE_BINARY_DIR}/build/${APP_BUNDLE_NAME}") - set(APP_BUNDLE_CONTENTS_DIR "${APP_BUNDLE_DIR}/Contents") - set(APP_BUNDLE_BINARY_DIR "${APP_BUNDLE_CONTENTS_DIR}/MacOS") - set(APP_BUNDLE_RESOURCES_DIR "${APP_BUNDLE_CONTENTS_DIR}/Resources") -endif() - macro(vcmi_set_output_dir name dir) # Multi-config builds for Visual Studio, Xcode - foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) + foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGUPPERCASE) set_target_properties(${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/bin/${OUTPUTCONFIG}/${dir}) set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/bin/${OUTPUTCONFIG}/${dir}) diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index f24f2d495..fb57cbf8f 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -110,8 +110,16 @@ vcmi_set_output_dir(vcmilauncher "") #set_target_properties(vcmilauncher PROPERTIES ${PCH_PROPERTIES}) #cotire(vcmilauncher) -if(NOT APPLE) # Already inside bundle - install(TARGETS vcmilauncher DESTINATION ${BIN_DIR}) - # copy whole directory - install(DIRECTORY icons DESTINATION ${DATA_DIR}/launcher) +# Copy to build directory for easier debugging +add_custom_command(TARGET vcmilauncher POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/launcher/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons +) + +install(TARGETS vcmilauncher DESTINATION ${BIN_DIR}) +# copy whole directory +install(DIRECTORY icons DESTINATION ${DATA_DIR}/launcher) +# Install icons and desktop file on Linux +if(NOT WIN32 AND NOT APPLE) + install(FILES "vcmilauncher.desktop" DESTINATION share/applications) endif() diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 05d84cd34..fafd240d2 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -308,6 +308,12 @@ vcmi_set_output_dir(vcmi "") set_target_properties(vcmi PROPERTIES ${PCH_PROPERTIES}) cotire(vcmi) -if(NOT APPLE) # Already inside vcmiclient bundle - install(TARGETS vcmi RUNTIME DESTINATION ${LIB_DIR} LIBRARY DESTINATION ${LIB_DIR}) -endif() +# We want to deploy assets into build directory for easier debugging without install +add_custom_command(TARGET vcmi POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/config + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/Mods + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/config ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/config + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Mods ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/Mods +) + +install(TARGETS vcmi RUNTIME DESTINATION ${LIB_DIR} LIBRARY DESTINATION ${LIB_DIR}) diff --git a/lib/VCMIDirs.cpp b/lib/VCMIDirs.cpp index 61c580656..897e0653f 100644 --- a/lib/VCMIDirs.cpp +++ b/lib/VCMIDirs.cpp @@ -452,7 +452,7 @@ bfs::path VCMIDirsOSX::userConfigPath() const { return userDataPath() / "config" std::vector VCMIDirsOSX::dataPaths() const { - return std::vector(1, "../Data"); + return std::vector(1, "../Resources/Data"); } bfs::path VCMIDirsOSX::libraryPath() const { return "."; } diff --git a/lib/minizip/CMakeLists.txt b/lib/minizip/CMakeLists.txt index fa625af67..f2d966af1 100644 --- a/lib/minizip/CMakeLists.txt +++ b/lib/minizip/CMakeLists.txt @@ -19,6 +19,4 @@ vcmi_set_output_dir(minizip "") target_link_libraries(minizip ${ZLIB_LIBRARIES}) -if (NOT APPLE) # Already inside vcmiclient bundle - install(TARGETS minizip RUNTIME DESTINATION ${LIB_DIR} LIBRARY DESTINATION ${LIB_DIR}) -endif() +install(TARGETS minizip RUNTIME DESTINATION ${LIB_DIR} LIBRARY DESTINATION ${LIB_DIR}) diff --git a/osx/CMakeLists.txt b/osx/CMakeLists.txt new file mode 100644 index 000000000..3a8145796 --- /dev/null +++ b/osx/CMakeLists.txt @@ -0,0 +1,18 @@ +# We need to keep this code into separate directory so CMake will execute it after all other subdirectories install code +# Otherwise we can't fix Mac bundle dependencies since binaries wouldn't be there when this code executed +if(APPLE) + if(ENABLE_LAUNCHER) + find_program(TOOL_MACDEPLOYQT NAMES macdeployqt PATHS ${qt_base_dir}/bin) + if(NOT TOOL_MACDEPLOYQT) + message(FATAL_ERROR "Could not find macdeployqt") + endif() + install(CODE " + execute_process(COMMAND ${TOOL_MACDEPLOYQT} \"\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}\" -verbose=2)") + endif() + + install(CODE " + set(BU_CHMOD_BUNDLE_ITEMS ON) + include(BundleUtilities) + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}\" \"\" \"\") + " COMPONENT Runtime) +endif(APPLE) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 517553876..e2ace12ad 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -41,6 +41,4 @@ vcmi_set_output_dir(vcmiserver "") set_target_properties(vcmiserver PROPERTIES ${PCH_PROPERTIES}) cotire(vcmiserver) -if(NOT APPLE) # Already inside vcmiclient bundle - install(TARGETS vcmiserver DESTINATION ${BIN_DIR}) -endif() +install(TARGETS vcmiserver DESTINATION ${BIN_DIR}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 31f00d18d..c904a93f8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,8 +2,8 @@ enable_testing() set(googleTest_Dir ${CMAKE_CURRENT_SOURCE_DIR}/googletest) if(EXISTS ${googleTest_Dir}) - SET(GTestSrc ${googleTest_Dir}/googletest) - SET(GMockSrc ${googleTest_Dir}/googlemock) + set(GTestSrc ${googleTest_Dir}/googletest) + set(GMockSrc ${googleTest_Dir}/googlemock) else() message(FATAL_ERROR "No googletest src dir found!") endif()