diff --git a/AI/BattleAI/CMakeLists.txt b/AI/BattleAI/CMakeLists.txt index 52c5526ce..096d10b0c 100644 --- a/AI/BattleAI/CMakeLists.txt +++ b/AI/BattleAI/CMakeLists.txt @@ -1,6 +1,3 @@ -project(battleAI) -cmake_minimum_required(VERSION 2.6) - include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib) set(battleAI_SRCS @@ -28,9 +25,12 @@ set(battleAI_HEADERS ThreatMap.h ) -if (ANDROID) # android compiles ai libs into main lib directly, so we skip this library and just reuse sources list +assign_source_group(${battleAI_SRCS} ${battleAI_HEADERS}) + +if(ANDROID) # android compiles ai libs into main lib directly, so we skip this library and just reuse sources list return() endif() + add_library(BattleAI SHARED ${battleAI_SRCS} ${battleAI_HEADERS}) target_link_libraries(BattleAI vcmi) @@ -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/CMakeLists.txt b/AI/CMakeLists.txt index 64ea4bcab..6e9786950 100644 --- a/AI/CMakeLists.txt +++ b/AI/CMakeLists.txt @@ -1,20 +1,30 @@ -project(AI) -cmake_minimum_required(VERSION 2.8) +####################################### +# FuzzyLite support # +####################################### -option(FORCE_BUNDLED_FL "Force to use FuzzyLite included into VCMI's source tree" OFF) +if(NOT WIN32 AND NOT APPLE) + option(FORCE_BUNDLED_FL "Force to use FuzzyLite included into VCMI's source tree" ON) +else() + option(FORCE_BUNDLED_FL "Force to use FuzzyLite included into VCMI's source tree" OFF) +endif() -if (NOT FORCE_BUNDLED_FL) +if(NOT FORCE_BUNDLED_FL) find_package(FuzzyLite) else() set(FL_FOUND FALSE) endif() -if (NOT FL_FOUND) +if(NOT FL_FOUND) set(FL_BUILD_BINARY OFF CACHE BOOL "") set(FL_BUILD_SHARED OFF CACHE BOOL "") - set(FL_BUILD_TESTS OFF CACHE BOOL "") - add_subdirectory(FuzzyLite/fuzzylite) + set(FL_BUILD_TESTS OFF CACHE BOOL "") + add_subdirectory(FuzzyLite/fuzzylite EXCLUDE_FROM_ALL) endif() + +####################################### +# Add subdirectories # +####################################### + add_subdirectory(BattleAI) add_subdirectory(StupidAI) add_subdirectory(EmptyAI) diff --git a/AI/EmptyAI/CMakeLists.txt b/AI/EmptyAI/CMakeLists.txt index 2aeab301d..dc3d8c08d 100644 --- a/AI/EmptyAI/CMakeLists.txt +++ b/AI/EmptyAI/CMakeLists.txt @@ -1,6 +1,3 @@ -project(emptyAI) -cmake_minimum_required(VERSION 2.6) - include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib) set(emptyAI_SRCS @@ -16,11 +13,13 @@ set(emptyAI_HEADERS CEmptyAI.h ) +assign_source_group(${emptyAI_SRCS} ${emptyAI_HEADERS}) + add_library(EmptyAI SHARED ${emptyAI_SRCS} ${emptyAI_HEADERS}) target_link_libraries(EmptyAI vcmi) vcmi_set_output_dir(EmptyAI "AI") -if (NOT APPLE) # Already inside vcmiclient bundle - install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) -endif() +set_target_properties(EmptyAI PROPERTIES ${PCH_PROPERTIES}) + +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 a83fc5e35..cb083c425 100644 --- a/AI/StupidAI/CMakeLists.txt +++ b/AI/StupidAI/CMakeLists.txt @@ -1,6 +1,3 @@ -project(stupidAI) -cmake_minimum_required(VERSION 2.6) - include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib) set(stupidAI_SRCS @@ -16,6 +13,8 @@ set(stupidAI_HEADERS StupidAI.h ) +assign_source_group(${stupidAI_SRCS} ${stupidAI_HEADERS}) + add_library(StupidAI SHARED ${stupidAI_SRCS} ${stupidAI_HEADERS}) target_link_libraries(StupidAI vcmi) @@ -24,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 07a635ba6..d49a96375 100644 --- a/AI/VCAI/CMakeLists.txt +++ b/AI/VCAI/CMakeLists.txt @@ -1,10 +1,7 @@ -project(VCAI) -cmake_minimum_required(VERSION 2.6) - -if (FL_FOUND) - include_directories(${FL_INCLUDE_DIRS}) +if(FL_FOUND) + include_directories(${FL_INCLUDE_DIRS}) else() - include_directories(${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite) + include_directories(${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite) endif() include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib) @@ -27,12 +24,14 @@ set(VCAI_HEADERS VCAI.h ) -if (ANDROID) # android compiles ai libs into main lib directly, so we skip this library and just reuse sources list +assign_source_group(${VCAI_SRCS} ${VCAI_HEADERS}) + +if(ANDROID) # android compiles ai libs into main lib directly, so we skip this library and just reuse sources list return() 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) @@ -43,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/CI/appveyor.yml b/CI/appveyor.yml index 32a529888..5125c759b 100644 --- a/CI/appveyor.yml +++ b/CI/appveyor.yml @@ -1,72 +1,105 @@ +# Common configuration for all branches version: 1.0.{build} max_jobs: 2 clone_depth: 10 clone_folder: c:\projects\vcmi\source -init: -- cmd: set QTDIR=C:\Qt\5.7\msvc2015 -environment: - BUILD_PLATFORM: x86 - BUILD_CONFIGURATION: Release install: -- cmd: >- - cd c:\projects\vcmi\ - - curl -fsS -o vcmi_depends_%BUILD_PLATFORM%.zip https://dependencies.vcmi.download/msvc/vcmi_depends_%BUILD_PLATFORM%.zip - - 7z x vcmi_depends_%BUILD_PLATFORM%.zip -odepends - - cd source - - git submodule update --init --recursive - - cd .. - - mkdir build_%BUILD_PLATFORM% - - cd build_%BUILD_PLATFORM% - - cmake -DCMAKE_TOOLCHAIN_FILE=../source/CI/msvc/appveyor_toolchain.txt ../source +- bash c:\projects\vcmi\source\CI\msvc\install.sh build_script: -- cmd: >- - cd c:\projects\vcmi\build_%BUILD_PLATFORM% - - msbuild vcmi.sln /p:configuration=%BUILD_CONFIGURATION% /maxcpucount:2 - - IF "%APPVEYOR_REPO_TAG%"=="true" cpack - - - mkdir dist_%BUILD_PLATFORM% - - copy %BUILD_CONFIGURATION%\*.exe dist_%BUILD_PLATFORM% - - copy %BUILD_CONFIGURATION%\*.dll dist_%BUILD_PLATFORM% - - copy %BUILD_CONFIGURATION%\lib\*.dll dist_%BUILD_PLATFORM% - - mkdir dist_%BUILD_PLATFORM%\AI - - copy %BUILD_CONFIGURATION%\AI\*.dll dist_%BUILD_PLATFORM%\AI - - cd dist_%BUILD_PLATFORM% - - mkdir platforms - - copy %QTDIR%\bin\Qt5Core.dll . - - copy %QTDIR%\bin\Qt5Gui.dll . - - copy %QTDIR%\bin\Qt5Widgets.dll . - - copy %QTDIR%\bin\Qt5Network.dll . - - copy %QTDIR%\plugins\platforms\qwindows.dll platforms - - 7z a c:\projects\vcmi\source\vcmi-%BUILD_PLATFORM%-%BUILD_CONFIGURATION%.zip * -mx=7 -r -x!*.exp -x!*.lib - - 7z a c:\projects\vcmi\source\vcmi-%BUILD_PLATFORM%-%BUILD_CONFIGURATION%.zip c:\projects\vcmi\depends\bin\*.dll -mx=7 +- cmd: c:\projects\vcmi\source\CI\msvc\build_script.bat artifacts: -- path: vcmi-x86-Release.zip +- path: build_$(VCMI_BUILD_PLATFORM)\*.exe notifications: - provider: Slack incoming_webhook: secure: zxT3HTnxL744HiSv7ig7sjGL4LmJ8n3MsY8PEA/kinbVMkmcxrSgVBVkHV79RfSWSyq4oLMSRvMMpG8SuDWnf6oK/qvgaiAWfwwlCIiA7uQ= + +# Branch-specific configuration +for: +# Extended configuration for toolchain_test branch +- + branches: + only: + - toolchain_test + environment: + matrix: + - NAME: MSVS 2015 x86 - Release + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + VCMI_GENERATOR: Visual Studio 14 2015 + VCMI_BUILD_PLATFORM: x86 + VCMI_BUILD_CONFIGURATION: Release + - NAME: MSVS 2015 x86 - Debug + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + VCMI_GENERATOR: Visual Studio 14 2015 + VCMI_BUILD_PLATFORM: x86 + VCMI_BUILD_CONFIGURATION: Debug + + - NAME: MSVS 2015 x64 - Release + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + VCMI_GENERATOR: Visual Studio 14 2015 Win64 + VCMI_BUILD_PLATFORM: x64 + VCMI_BUILD_CONFIGURATION: Release + - NAME: MSVS 2015 x64 - Debug + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + VCMI_GENERATOR: Visual Studio 14 2015 Win64 + VCMI_BUILD_PLATFORM: x64 + VCMI_BUILD_CONFIGURATION: Debug + + - NAME: MSVS 2017 x86 - Release + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + VCMI_GENERATOR: Visual Studio 15 2017 + VCMI_BUILD_PLATFORM: x86 + VCMI_BUILD_CONFIGURATION: Release + - NAME: MSVS 2017 x86 - Debug + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + VCMI_GENERATOR: Visual Studio 15 2017 + VCMI_BUILD_PLATFORM: x86 + VCMI_BUILD_CONFIGURATION: Debug + + - NAME: MSVS 2017 x64 - Release + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + VCMI_GENERATOR: Visual Studio 15 2017 Win64 + VCMI_BUILD_PLATFORM: x64 + VCMI_BUILD_CONFIGURATION: Release + - NAME: MSVS 2017 x64 - Debug + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + VCMI_GENERATOR: Visual Studio 15 2017 Win64 + VCMI_BUILD_PLATFORM: x64 + VCMI_BUILD_CONFIGURATION: Debug + +# Special configuration for coverity_scan branch +- + branches: + only: + - coverity_scan + environment: + matrix: + - NAME: Coverity - MSVS 2015 x86 - Release + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + VCMI_GENERATOR: Visual Studio 14 2015 + VCMI_BUILD_PLATFORM: x86 + VCMI_BUILD_CONFIGURATION: Release + environment: + coverity_token: + secure: XNnpYevnZxGmXW1zLu+3js2S+pqfWPQmL26hVgOTBTI= + coverity_email: + secure: JDd5yXvYaq/yJEVjoadEhA== + build_script: + - cmd: c:\projects\vcmi\source\CI\msvc\coverity_build_script.bat + after_test: + - ps: c:\projects\vcmi\source\CI\msvc\coverity_upload_script.ps + +# Default configuration for all other branches +- + environment: + matrix: + - NAME: MSVS 2015 x86 - Release + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + VCMI_GENERATOR: Visual Studio 14 2015 + VCMI_BUILD_PLATFORM: x86 + VCMI_BUILD_CONFIGURATION: Release + - NAME: MSVS 2017 x64 - Release + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + VCMI_GENERATOR: Visual Studio 15 2017 Win64 + VCMI_BUILD_PLATFORM: x64 + VCMI_BUILD_CONFIGURATION: Release diff --git a/CI/get_package_name.sh b/CI/get_package_name.sh index 8c2b2ccb1..1a1659735 100644 --- a/CI/get_package_name.sh +++ b/CI/get_package_name.sh @@ -1,14 +1,33 @@ #!/bin/sh -VCMI_PACKAGE_FILE_NAME="${TRAVIS_JOB_ID}-vcmi" -VCMI_PACKAGE_NAME_SUFFIX="" -if [ "$TRAVIS_PULL_REQUEST" = "false" ]; +if [ ! -z "$TRAVIS_JOB_ID" ]; then - branch_name=$(echo "$TRAVIS_BRANCH" | sed 's/[^[:alnum:]]\+/_/g') - VCMI_PACKAGE_FILE_NAME="${VCMI_PACKAGE_FILE_NAME}-branch-${branch_name}-${TRAVIS_COMMIT}" + echo "Using Travis environment variables!" + TMP_JOBID="$TRAVIS_JOB_ID" + TMP_BRANCH="$TRAVIS_BRANCH" + TMP_PRID="$TRAVIS_PULL_REQUEST" + TMP_COMMIT="$TRAVIS_COMMIT" +elif [ ! -z "${APPVEYOR_JOB_ID}" ]; +then + echo "Using AppVeyor environment variables!" + TMP_JOBID=$(echo "$APPVEYOR_JOB_ID" | sed 's/[^[:digit:]]\+//g') + TMP_BRANCH="$APPVEYOR_REPO_BRANCH" + TMP_PRID="$APPVEYOR_PULL_REQUEST_NUMBER" + TMP_COMMIT="$APPVEYOR_REPO_COMMIT" +else + echo "No Travir or AppVeyor environment variables found!" + exit +fi + +VCMI_PACKAGE_FILE_NAME="${TMP_JOBID}-vcmi" +VCMI_PACKAGE_NAME_SUFFIX="" +if [ -z "$TMP_PRID" ]; +then + branch_name=$(echo "$TMP_BRANCH" | sed 's/[^[:alnum:]]\+/_/g') + VCMI_PACKAGE_FILE_NAME="${VCMI_PACKAGE_FILE_NAME}-branch-${branch_name}-${TMP_COMMIT}" VCMI_PACKAGE_NAME_SUFFIX="branch ${branch_name}" else - VCMI_PACKAGE_FILE_NAME="${VCMI_PACKAGE_FILE_NAME}-PR-${TRAVIS_PULL_REQUEST}-${TRAVIS_COMMIT}" - VCMI_PACKAGE_NAME_SUFFIX="PR ${TRAVIS_PULL_REQUEST}" + VCMI_PACKAGE_FILE_NAME="${VCMI_PACKAGE_FILE_NAME}-PR-${TMP_PRID}-${TMP_COMMIT}" + VCMI_PACKAGE_NAME_SUFFIX="PR ${TMP_PRID}" fi VCMI_PACKAGE_NAME_SUFFIX="(${VCMI_PACKAGE_NAME_SUFFIX})" diff --git a/CI/msvc/appveyor_toolchain.txt b/CI/msvc/appveyor_toolchain.txt deleted file mode 100644 index 6754e72a6..000000000 --- a/CI/msvc/appveyor_toolchain.txt +++ /dev/null @@ -1,18 +0,0 @@ -SET(CMAKE_SYSTEM_NAME Windows) -SET(VCMIBUILD_DIR c:/projects/vcmi) - -SET(CMAKE_C_COMPILER cl) -SET(CMAKE_CXX_COMPILER cl) -set(CMAKE_RC_COMPILER rc) - - -SET(ENV{BOOST_ROOT} C:/Libraries/boost_1_60_0) -SET(ENV{BOOST_LIBRARYDIR} C:/Libraries/boost_1_60_0/lib32-msvc-14.0) - -SET(CMAKE_FIND_ROOT_PATH ${VCMIBUILD_DIR}/depends) -list(APPEND CMAKE_PREFIX_PATH ${CMAKE_FIND_ROOT_PATH}) -list(APPEND CMAKE_PREFIX_PATH C:/Qt/5.7/msvc2015) - -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) -SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) -SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) \ No newline at end of file diff --git a/CI/msvc/build_script.bat b/CI/msvc/build_script.bat new file mode 100644 index 000000000..5bd1d8485 --- /dev/null +++ b/CI/msvc/build_script.bat @@ -0,0 +1,6 @@ +cd %APPVEYOR_BUILD_FOLDER% +cd build_%VCMI_BUILD_PLATFORM% + +cmake --build . --config %VCMI_BUILD_CONFIGURATION% -- /maxcpucount:2 + +cpack diff --git a/CI/msvc/coverity_build_script.bat b/CI/msvc/coverity_build_script.bat new file mode 100644 index 000000000..9fe2cbf2a --- /dev/null +++ b/CI/msvc/coverity_build_script.bat @@ -0,0 +1,5 @@ +cd %APPVEYOR_BUILD_FOLDER% +cd build_%VCMI_BUILD_PLATFORM% + +echo Building with coverity... +cov-build.exe --dir cov-int cmake --build . --config %VCMI_BUILD_CONFIGURATION% -- /maxcpucount:2 diff --git a/CI/msvc/coverity_upload_script.ps b/CI/msvc/coverity_upload_script.ps new file mode 100644 index 000000000..e830ae970 --- /dev/null +++ b/CI/msvc/coverity_upload_script.ps @@ -0,0 +1,17 @@ +7z a "$Env:APPVEYOR_BUILD_FOLDER\$Env:APPVEYOR_PROJECT_NAME.zip" "$Env:APPVEYOR_BUILD_FOLDER\build_$Env:VCMI_BUILD_PLATFORM\cov-int\" + +# cf. http://stackoverflow.com/a/25045154/335418 +Remove-item alias:curl + +Write-Host "Uploading Coverity analysis result..." -ForegroundColor "Green" + +curl --silent --show-error ` + --output curl-out.txt ` + --form token="$Env:coverity_token" ` + --form email="$Env:coverity_email" ` + --form "file=@$Env:APPVEYOR_BUILD_FOLDER\$Env:APPVEYOR_PROJECT_NAME.zip" ` + --form version="$Env:APPVEYOR_REPO_COMMIT" ` + --form description="CI server scheduled build." ` + https://scan.coverity.com/builds?project=vcmi%2Fvcmi + +cat .\curl-out.txt diff --git a/CI/msvc/install.sh b/CI/msvc/install.sh new file mode 100644 index 000000000..ce6f5db25 --- /dev/null +++ b/CI/msvc/install.sh @@ -0,0 +1,17 @@ +cd $APPVEYOR_BUILD_FOLDER +git submodule update --init --recursive + +cd .. + +curl -LfsS -o "vcpkg-export-${VCMI_BUILD_PLATFORM}-windows-v140.7z" \ + "https://github.com/vcmi/vcmi-deps-windows/releases/download/v1/vcpkg-export-${VCMI_BUILD_PLATFORM}-windows-v140.7z" +7z x "vcpkg-export-${VCMI_BUILD_PLATFORM}-windows-v140.7z" + +cd $APPVEYOR_BUILD_FOLDER +mkdir build_$VCMI_BUILD_PLATFORM +cd build_$VCMI_BUILD_PLATFORM + +source $APPVEYOR_BUILD_FOLDER/CI/get_package_name.sh +cmake -G "$VCMI_GENERATOR" .. -DCMAKE_TOOLCHAIN_FILE=$APPVEYOR_BUILD_FOLDER/../vcpkg/scripts/buildsystems/vcpkg.cmake \ + -DPACKAGE_NAME_SUFFIX:STRING="$VCMI_PACKAGE_NAME_SUFFIX" \ + -DPACKAGE_FILE_NAME:STRING="$VCMI_PACKAGE_FILE_NAME" diff --git a/CMakeLists.txt b/CMakeLists.txt index a03e36e0d..11f6821e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,33 +1,112 @@ -project(vcmi) +# Minimum required version greatly affect CMake behavior +# So cmake_minimum_required must be called before the project() +# 2.8.12 is used since it's present in Ubuntu 14.04 and Cotire require it cmake_minimum_required(VERSION 2.8.12) -# TODO: -# 1) Detection of Qt5 and compilation of launcher, unless explicitly disabled -# where to look for cmake modules -set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules) +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. +# - 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. +# +# MXE: +# - Try to implement MXE support into BundleUtilities so we can deploy deps automatically +# +# Vckpg: +# - Improve install code once there is better way to deploy DLLs and Qt plugins +# - Move Vcpkg install BundleUtilities code from osx/CMakeLists.txt +# +# Other: +# - Cleanup remove_directory copy_directory if performance will be a problem. +# We can use some macro over copy_if_different since it's only work for single file. +# - Find a way to move add_custom_command for assets deploy out of "lib/CMakeLists.txt" +# - Consider to remove M_DATA_DIR, DM_BIN_DIR, DM_LIB_DIR and not use them in code as well +# - Try to get rid of FOLDER override with define_property +# It's used currently to make sure that 3rd-party dependencies in git submodules get proper FOLDER property +# - Make FindFuzzyLite check for the right version and disable FORCE_BUNDLED_FL by default +# - Find a way to regenerate Version.cpp before each build. +# PRE_BUILD only work for some generators. +# So for now commit hash only updated when CMake reconfigured. -include(VCMIUtils) +############################################ +# User-provided options # +############################################ -# enable Release mode but only if it was not set -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RelWithDebInfo) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING + "Choose the type of build, options are: Debug Release RelWithDebInfo. Default is RelWithDebInfo." + FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo) endif() -# VCMI version set(VCMI_VERSION_MAJOR 0) set(VCMI_VERSION_MINOR 99) set(VCMI_VERSION_PATCH 0) -# 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") - option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF) 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) -# TODO: default to ON when we start distributing macOS binaries -option(ENABLE_SPARKLE "Enable auto-updating with Sparkle on macOS" OFF) +option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON) +option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" 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") + +############################################ +# Miscellaneous options # +############################################ + +set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules) +# Contains custom functions and macros, but don't altering any options +include(VCMIUtils) + +# Options to enable folders in CMake generated projects for Visual Studio, Xcode, etc +# Very useful to put 3rd-party libraries such as Minizip, GoogleTest and FuzzyLite in their own folders +set_property(GLOBAL PROPERTY USE_FOLDERS TRUE) +# Make FOLDER property inheritable +# So when we set FOLDER property on AI directory all and targets inside will inherit it +# +# Important! This trick depend on undefined behavior since we override CMake own property. +# In same time define_property documentation states it's function for custom properties. +define_property( + TARGET + PROPERTY FOLDER + INHERITED + BRIEF_DOCS "Set the folder name." + FULL_DOCS "Use to organize targets in an IDE." +) + +# Generate Version.cpp +if(ENABLE_GITVERSION) + 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) +else() + add_definitions(-DVCMI_NO_EXTRA_VERSION) +endif(ENABLE_GITVERSION) + +# Precompiled header configuration +if(ENABLE_PCH) + include(cotire) + set(PCH_PROPERTIES + COTIRE_ENABLE_PRECOMPILED_HEADER ${ENABLE_PCH} + COTIRE_ADD_UNITY_BUILD FALSE + COTIRE_CXX_PREFIX_HEADER_INIT "StdInc.h" + ) +else() + set(PCH_PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) + macro(cotire ignore) + endmacro(cotire) +endif(ENABLE_PCH) ############################################ # Documentation section # @@ -36,104 +115,94 @@ option(ENABLE_SPARKLE "Enable auto-updating with Sparkle on macOS" OFF) include(UseDoxygen OPTIONAL) ############################################ -# Building section # +# Compile and linking options # ############################################ -if (APPLE) - # Default location for thirdparty libs - set(CMAKE_INCLUDE_PATH "../include" "${CMAKE_OSX_SYSROOT}/usr/include") - set(CMAKE_LIBRARY_PATH "../lib") - set(CMAKE_FRAMEWORK_PATH "../Frameworks") - set(BOOST_ROOT "../") +if(APPLE) + set(CMAKE_MACOSX_RPATH 0) +endif(APPLE) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin") - - set(CMAKE_XCODE_ATTRIBUTE_CONFIGURATION_BUILD_DIR "${CMAKE_HOME_DIRECTORY}/bin/$(CONFIGURATION)") - set(CMAKE_XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks @executable_path/") - - # Build with clang ang libc++ - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - - if(ENABLE_SPARKLE) - # so that OSX_checkForUpdates knows whether to be a noop - add_definitions(-DSPARKLE) - - # On OS X we use Sparkle framework for updates - find_path(SPARKLE_INCLUDE_DIR Sparkle.h) - find_library(SPARKLE_FRAMEWORK NAMES Sparkle) - endif() - - # Xcode 5.0 fix - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=256") - - # Link with iconv - set(SYSTEM_LIBS ${SYSTEM_LIBS} libiconv.dylib) -endif() - -if (WIN32) +if(WIN32) add_definitions(-DBOOST_THREAD_USE_LIB) # Windows Vista or newer for FuzzyLite 6 to compile add_definitions(-D_WIN32_WINNT=0x0600) - set(SYSTEM_LIBS ${SYSTEM_LIBS} ole32 oleaut32 ws2_32 mswsock dbghelp) #delete lib prefix for dlls (libvcmi -> vcmi) set(CMAKE_SHARED_LIBRARY_PREFIX "") + if(MSVC) + add_definitions(-DBOOST_ALL_NO_LIB) + set(Boost_USE_STATIC_LIBS OFF) + + # Don't link with SDLMain + if(ENABLE_DEBUG_CONSOLE) + set(SDL2_BUILDING_LIBRARY ON) + add_definitions(-DVCMI_WITH_DEBUG_CONSOLE) + endif() + + # Suppress warnings + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_SCL_SECURE_NO_WARNINGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /wd4251") + endif(MSVC) + if(MINGW) - #MinGW: check for iconv (may be needed for boost.locale) + set(SYSTEM_LIBS ${SYSTEM_LIBS} ole32 oleaut32 ws2_32 mswsock dbghelp) + + # Check for iconv (may be needed for Boost.Locale) include(CheckLibraryExists) check_library_exists(iconv libiconv_open "" ICONV_FOUND) if(ICONV_FOUND) set(SYSTEM_LIBS ${SYSTEM_LIBS} iconv) endif() - #MinGW: copy runtime to VCMI location - get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} PATH ) - set(dep_files ${dep_files} "${MINGW_BIN_PATH}/libwinpthread-*.dll") - set(dep_files ${dep_files} "${MINGW_BIN_PATH}/libgcc_s_*.dll") - set(dep_files ${dep_files} "${MINGW_BIN_PATH}/libstdc++-*.dll") + # Prevent compiler issues when building Debug + # Assembler might fail with "too many sections" + # With big-obj or 64-bit build will take hours + if(CMAKE_BUILD_TYPE MATCHES Debug) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og") + endif() + endif(MINGW) +endif(WIN32) - #MinGW: use O1 to prevent compiler crash in some cases - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1") +if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32) #so far all *nix compilers support such parameters + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wpointer-arith -Wuninitialized") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing -Wno-switch -Wno-sign-compare -Wno-unused-local-typedefs") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-overloaded-virtual -Wno-type-limits -Wno-unknown-pragmas") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder") + + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-mismatched-tags -Wno-unknown-warning-option") endif() - if(MSVC) - #MSVC: Fix problems with linking - add_definitions(-DBOOST_ALL_NO_LIB) - set(Boost_USE_STATIC_LIBS ON) - - #MSVC: Don't link with SDLMain - set(SDL2_BUILDING_LIBRARY ON) - - #MSVC: Suppress warnings - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_definitions(-D_SCL_SECURE_NO_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /wd4251") + if(UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") endif() endif() +# Check if some platform-specific libraries are needed for linking if(NOT WIN32) - INCLUDE(CheckLibraryExists) + include(CheckLibraryExists) - #check if some platform-specific libraries are needed for linking + # Shared memory functions used by Boost.Interprocess + # FindBoost handle linking with pthreads, but doesn't handle this CHECK_LIBRARY_EXISTS(rt shm_open "" HAVE_RT_LIB) if(HAVE_RT_LIB) set(SYSTEM_LIBS ${SYSTEM_LIBS} rt) endif() endif() -set(SYSTEM_LIBS ${SYSTEM_LIBS} ${CMAKE_DL_LIBS}) +############################################ +# Finding packages # +############################################ set(FFmpeg_FIND_COMPONENTS AVFORMAT SWSCALE) find_package(Boost 1.48.0 COMPONENTS date_time filesystem locale program_options system thread REQUIRED) find_package(ZLIB REQUIRED) find_package(FFmpeg REQUIRED) find_package(Minizip) -if (MINIZIP_FOUND) - add_definitions(-DUSE_SYSTEM_MINIZIP) +if(MINIZIP_FOUND) + add_definitions(-DUSE_SYSTEM_MINIZIP) endif() find_package(SDL2 REQUIRED) @@ -141,43 +210,15 @@ find_package(SDL2_image REQUIRED) find_package(SDL2_mixer REQUIRED) find_package(SDL2_ttf REQUIRED) -set(SDL_INCLUDE_DIR "${SDL2_INCLUDE_DIR}") -set(SDLTTF_INCLUDE_DIR "${SDL2_TTF_INCLUDE_DIR}") -set(SDLIMAGE_INCLUDE_DIR "${SDL2_IMAGE_INCLUDE_DIR}") -set(SDLMIXER_INCLUDE_DIR "${SDL2_MIXER_INCLUDE_DIR}") -set(SDL_LIBRARY "${SDL2_LIBRARY}") -set(SDLTTF_LIBRARY "${SDL2_TTF_LIBRARY}") -set(SDLIMAGE_LIBRARY "${SDL2_IMAGE_LIBRARY}") -set(SDLMIXER_LIBRARY "${SDL2_MIXER_LIBRARY}") - -include(cotire) - if(ENABLE_LAUNCHER) # Widgets finds its own dependencies (QtGui and QtCore). find_package(Qt5Widgets REQUIRED) -endif() - -if (ENABLE_LAUNCHER) find_package(Qt5Network REQUIRED) endif() -if(ENABLE_TEST) - # find_package overwrites BOOST_* variables which are already set, so all components have to be included again - find_package(Boost 1.48.0 COMPONENTS date_time program_options filesystem system thread locale REQUIRED) -endif() - -if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32) #so far all *nix compilers support such parameters - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CLANG_SPECIFIC_FLAGS "-Wno-mismatched-tags -Wno-unknown-warning-option") - endif() - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wpointer-arith -Wno-strict-aliasing -Wno-switch -Wno-sign-compare -Wno-unused-local-typedefs -Wno-unused-parameter -Wuninitialized -Wno-overloaded-virtual -Wno-type-limits -Wno-unknown-pragmas -Wno-reorder ${CLANG_SPECIFIC_FLAGS}") - - if(UNIX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") - endif() - -endif() +############################################ +# Output directories # +############################################ if(WIN32) # on Win everything goes into H3 root directory set(BIN_DIR "." CACHE STRING "Where to install binaries") @@ -187,54 +228,65 @@ 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) +####################################### +# Add subdirectories # +####################################### -# precompiled header configuration -SET(PCH_PROPERTIES - COTIRE_ENABLE_PRECOMPILED_HEADER ${ENABLE_PCH} - COTIRE_ADD_UNITY_BUILD FALSE - COTIRE_CXX_PREFIX_HEADER_INIT "StdInc.h" -) - -if (ENABLE_ERM) - add_subdirectory(scripting/erm) +if(ENABLE_ERM) + add_subdirectory(scripting/erm) endif() -if (NOT MINIZIP_FOUND) - add_subdirectory(lib/minizip) +if(NOT MINIZIP_FOUND) + add_subdirectory_with_folder("3rdparty" lib/minizip) set(MINIZIP_LIBRARIES minizip) endif() add_subdirectory(lib) add_subdirectory(client) add_subdirectory(server) -add_subdirectory(AI) -if (ENABLE_LAUNCHER) +add_subdirectory_with_folder("AI" AI) +if(ENABLE_LAUNCHER) add_subdirectory(launcher) endif() if(ENABLE_TEST) @@ -242,34 +294,31 @@ 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() +# 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() -if(WIN32) +if(MINGW) file(GLOB dep_files ${dep_files} "${CMAKE_FIND_ROOT_PATH}/bin/*.dll") - #Copy debug versions of libraries if build type is debug. Doesn't work in MSVC! - if(CMAKE_BUILD_TYPE MATCHES DEBUG) + if((${CMAKE_CROSSCOMPILING}) AND (DEFINED MSYS)) + message(STATUS "Detected MXE build") + elseif(CMAKE_BUILD_TYPE MATCHES Debug) + # Copy debug versions of libraries if build type is debug set(debug_postfix d) - endif(CMAKE_BUILD_TYPE MATCHES DEBUG) + endif() if(ENABLE_LAUNCHER) get_target_property(QtCore_location Qt5::Core LOCATION) @@ -282,12 +331,6 @@ if(WIN32) ${Qtbin_folder}/icu*.dll) file(GLOB dep_qwindows ${Qtbin_folder}/../plugins/platforms/qwindows${debug_postfix}.dll) - if(MSVC) - file(GLOB dep_files - ${dep_files} - ${Qtbin_folder}/libEGL.dll - ${Qtbin_folder}/libGLESv2.dll) - endif() endif() if (ENABLE_LAUNCHER) @@ -296,25 +339,9 @@ if(WIN32) ${Qtbin_folder}/Qt5Network${debug_postfix}.dll) endif() - if(MSVC) - #install MSVC runtime - include(InstallRequiredSystemLibraries) - install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ${BIN_DIR}) - endif() install(FILES ${dep_files} DESTINATION ${BIN_DIR}) install(FILES ${dep_qwindows} DESTINATION ${BIN_DIR}/platforms) -elseif(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() -endif() +endif(MINGW) ####################################### # Packaging section # @@ -343,9 +370,9 @@ endif() set(CPACK_PACKAGE_VENDOR "VCMI team") if(WIN32) + # Note: due to NSI script generation process all of the backward slashes here are useful set(CPACK_MONOLITHIC_INSTALL 1) - set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt") - set(CPACK_PACKAGE_EXECUTABLES "VCMI_launcher;VCMI") + set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt") set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") if("${PACKAGE_NAME_SUFFIX}" STREQUAL "") set(CPACK_NSIS_PACKAGE_NAME "VCMI ${CPACK_PACKAGE_VERSION}") @@ -353,21 +380,59 @@ 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_PACKAGE_EXECUTABLES "VCMI_launcher;VCMI") + set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " CreateShortCut \\\"$DESKTOP\\\\VCMI.lnk\\\" \\\"$INSTDIR\\\\VCMI_launcher.exe\\\"") + else() + set(CPACK_PACKAGE_EXECUTABLES "VCMI_client;VCMI") + 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) - set(CPACK_GENERATOR DragNDrop) + # set the install/unistall icon used for the installer itself + # There is a bug in NSI that does not handle full unix paths properly. + set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/client\\\\vcmi.ico") + set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/client\\\\vcmi.ico") + # set the package header icon for MUI + set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/client\\\\vcmi.ico") + + set(CPACK_NSIS_MENU_LINKS "http://vcmi.eu/" "VCMI Web Site") + + set(CPACK_NSIS_INSTALLED_ICON_NAME "VCMI_client.exe") + set(CPACK_NSIS_COMPRESSOR "/SOLID lzma") + set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_PACKAGE_NAME}, open-source engine for Heroes of Might and Magic III ") + set(CPACK_NSIS_HELP_LINK "http://vcmi.eu/") + set(CPACK_NSIS_URL_INFO_ABOUT "http://vcmi.eu/") + set(CPACK_NSIS_CONTACT @CPACK_PACKAGE_CONTACT@) + set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") + # Use BundleUtilities to fix build when Vcpkg is used and disable it for MXE + if(NOT (${CMAKE_CROSSCOMPILING})) + add_subdirectory(osx) + endif() +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() + set(MACOSX_BUNDLE_EXECUTABLE_NAME "vcmiclient") + endif() + set(MACOSX_BUNDLE_ICON_FILE "vcmi.icns") + + 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}) + + # 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() -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/Autoupdate.mm b/client/Autoupdate.mm deleted file mode 100644 index 6cd132e68..000000000 --- a/client/Autoupdate.mm +++ /dev/null @@ -1,11 +0,0 @@ -#ifdef SPARKLE -#import -#import "Sparkle.h" -#endif - -void OSX_checkForUpdates() { -#ifdef SPARKLE - SUUpdater* updater = [[SUUpdater alloc] init]; - [[SUUpdater sharedUpdater] checkForUpdatesInBackground]; -#endif -} diff --git a/client/CMT.cpp b/client/CMT.cpp index c84b3329a..debae5f2e 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -219,11 +219,7 @@ static void SDLLogCallback(void* userdata, logGlobal->debug("SDL(category %d; priority %d) %s", category, priority, message); } -#ifdef VCMI_APPLE -void OSX_checkForUpdates(); -#endif - -#if defined(VCMI_WINDOWS) && !defined (__GNUC__) +#if defined(VCMI_WINDOWS) && !defined(__GNUC__) && defined(VCMI_WITH_DEBUG_CONSOLE) int wmain(int argc, wchar_t* argv[]) #elif defined(VCMI_APPLE) || defined(VCMI_ANDROID) int SDL_main(int argc, char *argv[]) @@ -235,22 +231,10 @@ int main(int argc, char * argv[]) // boost will crash without this setenv("LANG", "C", 1); #endif -#ifdef VCMI_APPLE + +#ifndef VCMI_ANDROID // Correct working dir executable folder (not bundle folder) so we can use executable relative paths - std::string executablePath = argv[0]; - std::string workDir = executablePath.substr(0, executablePath.rfind('/')); - chdir(workDir.c_str()); - - // Check for updates - OSX_checkForUpdates(); - - // Check that game data is prepared. Otherwise run vcmibuilder helper application - FILE* check = fopen((VCMIDirs::get().userDataPath() / "game_data_prepared").string().c_str(), "r"); - if (check == nullptr) { - system("open ./vcmibuilder.app"); - return 0; - } - fclose(check); + boost::filesystem::current_path(boost::filesystem::system_complete(argv[0]).parent_path()); #endif std::cout << "Starting... " << std::endl; po::options_description opts("Allowed options"); diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 33c8bdd6f..692924f9e 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,8 +1,5 @@ -project(vcmiclient) -cmake_minimum_required(VERSION 2.6) - include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib) -include_directories(${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR} ${SDLMIXER_INCLUDE_DIR} ${SDLTTF_INCLUDE_DIR}) +include_directories(${SDL2_INCLUDE_DIR} ${SDL2_IMAGE_INCLUDE_DIR} ${SDL2_MIXER_INCLUDE_DIR} ${SDL2_TTF_INCLUDE_DIR}) include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS}) set(client_SRCS @@ -116,95 +113,52 @@ set(client_HEADERS SDLRWwrapper.h ) +assign_source_group(${client_SRCS} ${client_HEADERS} VCMI_client.rc) + if(ANDROID) # android needs client/server to be libraries, not executables, so we can't reuse the build part of this script return() endif() -if(MSVC) - # workaround ffmpeg linking problems - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") -endif() - if(APPLE) - # OS X specific source files - set(client_SRCS ${client_SRCS} SDLMain.m Autoupdate.mm Info.plist vcmi.icns ../osx/vcmi_dsa_public.pem) - - if(ENABLE_SPARKLE) - # OS X specific includes - include_directories(${SPARKLE_INCLUDE_DIR}) - - # OS X specific libraries - target_link_libraries(vcmiclient ${SPARKLE_FRAMEWORK}) - endif() - - add_executable(vcmiclient MACOSX_BUNDLE ${client_SRCS} ${client_HEADERS}) - - # Because server and AI libs would be copies to bundle they need to be built before client - add_dependencies(vcmiclient vcmiserver VCAI EmptyAI StupidAI BattleAI minizip) - - # Custom Info.plist - set_target_properties(vcmiclient PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) - - # Copy icon file and public key for Sparkle - set_source_files_properties(vcmi.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) - set_source_files_properties(../osx/vcmi_dsa_public.pem PROPERTIES MACOSX_PACKAGE_LOCATION Resources) - - set_target_properties(vcmiclient PROPERTIES XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks @executable_path/") - - # Copy server executable, libs and game data to bundle - set(BUNDLE_PATH ${CMAKE_HOME_DIRECTORY}/bin/$(CONFIGURATION)/vcmiclient.app/Contents) - - set(CopyVendoredMinizip - mkdir -p ${BUNDLE_PATH}/MacOS && cp ${CMAKE_BINARY_DIR}/build/$(CONFIGURATION)/lib/libminizip.dylib ${BUNDLE_PATH}/MacOS/libminizip.dylib) - - set(MakeVCMIBundle - # Copy all needed binaries - mkdir -p ${BUNDLE_PATH}/MacOS/AI && - cp ${CMAKE_BINARY_DIR}/build/$(CONFIGURATION)/vcmiserver ${BUNDLE_PATH}/MacOS/vcmiserver && - cp ${CMAKE_BINARY_DIR}/build/$(CONFIGURATION)/vcmiclient.app/Contents/MacOS/vcmiclient ${BUNDLE_PATH}/MacOS/vcmiclient && - cp ${CMAKE_BINARY_DIR}/build/$(CONFIGURATION)/libvcmi.dylib ${BUNDLE_PATH}/MacOS/libvcmi.dylib && - cp ${CMAKE_BINARY_DIR}/build/$(CONFIGURATION)/AI/libVCAI.dylib ${BUNDLE_PATH}/MacOS/AI/libVCAI.dylib && - cp ${CMAKE_BINARY_DIR}/build/$(CONFIGURATION)/AI/libStupidAI.dylib ${BUNDLE_PATH}/MacOS/AI/libStupidAI.dylib && - cp ${CMAKE_BINARY_DIR}/build/$(CONFIGURATION)/AI/libEmptyAI.dylib ${BUNDLE_PATH}/MacOS/AI/libEmptyAI.dylib && - cp ${CMAKE_BINARY_DIR}/build/$(CONFIGURATION)/AI/libBattleAI.dylib ${BUNDLE_PATH}/MacOS/AI/libBattleAI.dylib && - cp -r ${CMAKE_HOME_DIRECTORY}/osx/vcmibuilder.app ${BUNDLE_PATH}/MacOS/vcmibuilder.app && - - # Copy frameworks - sh -c 'cp -r ${CMAKE_HOME_DIRECTORY}/${CMAKE_FRAMEWORK_PATH} ${BUNDLE_PATH}/Frameworks/ || true' && - - # Copy vcmi data - mkdir -p ${BUNDLE_PATH}/Data && - mkdir -p ${BUNDLE_PATH}/Data/Mods && - mkdir -p ${BUNDLE_PATH}/Data/launcher && - cp -r ${CMAKE_HOME_DIRECTORY}/config/ ${BUNDLE_PATH}/Data/config/ && - cp -r ${CMAKE_HOME_DIRECTORY}/Mods/vcmi/ ${BUNDLE_PATH}/Data/Mods/vcmi/ && - sh -c 'cp -r ${CMAKE_HOME_DIRECTORY}/Mods/WoG/ ${BUNDLE_PATH}/Data/Mods/WoG/ || echo "Download WoG mod from http://wiki.vcmi.eu/index.php?title=Mod_list" ' && - sh -c 'cp -r ${CMAKE_HOME_DIRECTORY}/Mods/hota/ ${BUNDLE_PATH}/Data/Mods/hota/ || echo "Download HOTA mod from http://wiki.vcmi.eu/index.php?title=Mod_list" ' && - cp -r ${CMAKE_HOME_DIRECTORY}/launcher/icons/ ${BUNDLE_PATH}/Data/launcher/icons/) - - if(NOT MINIZIP_FOUND) - add_custom_command(TARGET vcmiclient POST_BUILD COMMAND ${CopyVendoredMinizip}) - endif() - - add_custom_command(TARGET vcmiclient POST_BUILD COMMAND ${MakeVCMIBundle}) + set(client_SRCS ${client_SRCS} SDLMain.m) elseif(WIN32) - add_executable(vcmiclient ${client_SRCS} ${client_HEADERS} VCMI_client.rc) -else() - add_executable(vcmiclient ${client_SRCS} ${client_HEADERS}) + set(client_ICON "VCMI_client.rc") endif() +if(ENABLE_DEBUG_CONSOLE) + add_executable(vcmiclient ${client_SRCS} ${client_HEADERS} ${client_ICON}) +else() + add_executable(vcmiclient WIN32 ${client_SRCS} ${client_HEADERS} ${client_ICON}) +endif(ENABLE_DEBUG_CONSOLE) + if(WIN32) - set_target_properties(vcmiclient PROPERTIES OUTPUT_NAME VCMI_client) + set_target_properties(vcmiclient + PROPERTIES + OUTPUT_NAME "VCMI_client" + PROJECT_LABEL "VCMI_client" + ) + if(NOT ENABLE_DEBUG_CONSOLE) + target_link_libraries(vcmiclient ${SDLMAIN_LIBRARY}) + endif() endif() -target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY} ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES} ${SYSTEM_LIBS}) - +target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} + ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${SDL2_MIXER_LIBRARY} ${SDL2_TTF_LIBRARY} + ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES} ${FFMPEG_EXTRA_LINKING_OPTIONS} ${SYSTEM_LIBS} +) vcmi_set_output_dir(vcmiclient "") set_target_properties(vcmiclient PROPERTIES ${PCH_PROPERTIES}) cotire(vcmiclient) - 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/client/Info.plist b/client/Info.plist deleted file mode 100644 index b34e65ec3..000000000 --- a/client/Info.plist +++ /dev/null @@ -1,16 +0,0 @@ - - - - - CFBundleIconFile - vcmi.icns - CFBundleVersion - ${VCMI_VERSION_MAJOR}.${VCMI_VERSION_MINOR} - CFBundleIdentifier - com.vcmi.vcmiclient - SUFeedURL - https://vcmi.eu/sparkle_appcast.xml - SUPublicDSAKeyFile - vcmi_dsa_public.pem - - diff --git a/cmake_modules/CMakeCPackOptions.cmake.in b/cmake_modules/CMakeCPackOptions.cmake.in deleted file mode 100644 index b39bc5030..000000000 --- a/cmake_modules/CMakeCPackOptions.cmake.in +++ /dev/null @@ -1,26 +0,0 @@ -# This file is configured at cmake time, and loaded at cpack time. -# To pass variables to cpack from cmake, they must be configured -# in this file. - -if(CPACK_GENERATOR MATCHES "NSIS") - set(CPACK_NSIS_INSTALL_ROOT "@CPACK_NSIS_INSTALL_ROOT@") - - # set the install/unistall icon used for the installer itself - # There is a bug in NSI that does not handle full unix paths properly. - set(CPACK_NSIS_MUI_ICON "@CMAKE_SOURCE_DIR@/client\\vcmi.ico") - set(CPACK_NSIS_MUI_UNIICON "@CMAKE_SOURCE_DIR@/client\\vcmi.ico") - # set the package header icon for MUI - set(CPACK_PACKAGE_ICON "@CMAKE_SOURCE_DIR@/client\\vcmi.ico") - - set(CPACK_NSIS_MENU_LINKS - "http://vcmi.eu/" "VCMI Web Site") - - set(CPACK_NSIS_INSTALLED_ICON_NAME "VCMI_client.exe") - set(CPACK_NSIS_COMPRESSOR "/SOLID lzma") - set(CPACK_NSIS_PACKAGE_NAME "@CPACK_NSIS_PACKAGE_NAME@") - set(CPACK_NSIS_DISPLAY_NAME "@CPACK_NSIS_PACKAGE_NAME@, open-source engine for Heroes of Might and Magic III ") - set(CPACK_NSIS_HELP_LINK "http://vcmi.eu/") - set(CPACK_NSIS_URL_INFO_ABOUT "http://vcmi.eu/") - set(CPACK_NSIS_CONTACT @CPACK_PACKAGE_CONTACT@) - set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") -endif() \ No newline at end of file diff --git a/cmake_modules/FindFFmpeg.cmake b/cmake_modules/FindFFmpeg.cmake index 1e0c9d1ea..4557d9d77 100644 --- a/cmake_modules/FindFFmpeg.cmake +++ b/cmake_modules/FindFFmpeg.cmake @@ -156,7 +156,7 @@ endforeach () # On OS X we ffmpeg libraries depend on VideoDecodeAcceleration and CoreVideo frameworks IF (APPLE) - SET(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} "-framework VideoDecodeAcceleration -framework CoreVideo -lbz2") + SET(FFMPEG_EXTRA_LINKING_OPTIONS "-framework VideoDecodeAcceleration -framework CoreVideo -lbz2") ENDIF() # Give a nice error message if some of the required vars are missing. diff --git a/cmake_modules/VCMIUtils.cmake b/cmake_modules/VCMIUtils.cmake index 9318bb491..a69bfd83d 100644 --- a/cmake_modules/VCMIUtils.cmake +++ b/cmake_modules/VCMIUtils.cmake @@ -1,18 +1,76 @@ -####################################### -# Output directories # -####################################### +# This file should contain custom functions and macro and them only. +# It's should not alter any configuration on inclusion +####################################### +# Build output path # +####################################### macro(vcmi_set_output_dir name dir) - # multi-config builds (e.g. msvc) - foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGUPPERCASE) - set_target_properties(${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/${OUTPUTCONFIG}/${dir}) - set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/${OUTPUTCONFIG}/${dir}) - set_target_properties(${name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/${OUTPUTCONFIG}/${dir}) + # Multi-config builds for Visual Studio, Xcode + 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}) + set_target_properties(${name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/bin/${OUTPUTCONFIG}/${dir}) endforeach() - # generic no-config case (e.g. with mingw or MacOS) - set_target_properties(${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/${dir}) - set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/${dir}) - set_target_properties(${name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/${dir}) + # Generic no-config case for Makefiles, Ninja. + # This is what Qt Creator is using + set_target_properties(${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${dir}) + set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${dir}) + set_target_properties(${name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${dir}) endmacro() + +####################################### +# Project generation # +####################################### + +# Let us have proper tree-like structure in IDEs such as Visual Studio +function(assign_source_group) + foreach(_source IN ITEMS ${ARGN}) + if(IS_ABSOLUTE "${_source}") + file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}") + else() + set(_source_rel "${_source}") + endif() + get_filename_component(_source_path "${_source_rel}" PATH) + string(REPLACE "/" "\\" _source_path_msvc "${_source_path}") + source_group("${_source_path_msvc}" FILES "${_source}") + endforeach() +endfunction(assign_source_group) + +# Macro to add subdirectory and set appropriate FOLDER for generated projects files +function(add_subdirectory_with_folder _folder_name _folder) + add_subdirectory(${_folder} ${ARGN}) + set_property(DIRECTORY "${_folder}" PROPERTY FOLDER "${_folder_name}") +endfunction() + +# Macro for Xcode Projects generation +# Slightly outdated, but useful reference for all options available here: +# https://pewpewthespells.com/blog/buildsettings.html +# https://github.com/samdmarshall/Xcode-Build-Settings-Reference +if(${CMAKE_GENERATOR} MATCHES "Xcode") + + macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) + set_property(TARGET ${TARGET} PROPERTY + XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE}) + endmacro(set_xcode_property) + +endif(${CMAKE_GENERATOR} MATCHES "Xcode") + +####################################### +# CMake debugging # +####################################### + +# Can be called to see check cmake variables and environment variables +# For "install" debugging just copy it here. There no easy way to include modules from source. +function(vcmi_get_cmake_debug_info) + + message(STATUS "Debug - Internal variables:") + get_cmake_property(_variableNames VARIABLES) + foreach(_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() + message(STATUS "Debug - Environment variables:") + execute_process(COMMAND "${CMAKE_COMMAND}" "-E" "environment") + +endfunction() diff --git a/cmake_modules/cotire.cmake b/cmake_modules/cotire.cmake index 741d6901f..62cd23db9 100644 --- a/cmake_modules/cotire.cmake +++ b/cmake_modules/cotire.cmake @@ -3,7 +3,7 @@ # See the cotire manual for usage hints. # #============================================================================= -# Copyright 2012-2016 Sascha Kratky +# Copyright 2012-2017 Sascha Kratky # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -43,7 +43,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.8") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.10") # activate select policies if (POLICY CMP0025) @@ -106,6 +106,11 @@ if (POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() +if (POLICY CMP0055) + # strict checking for break() command + cmake_policy(SET CMP0055 NEW) +endif() + include(CMakeParseArguments) include(ProcessorCount) @@ -293,7 +298,7 @@ function (cotire_get_source_file_property_values _valuesVar _property) set (${_valuesVar} ${_values} PARENT_SCOPE) endfunction() -function (cotire_resolve_config_properites _configurations _propertiesVar) +function (cotire_resolve_config_properties _configurations _propertiesVar) set (_properties "") foreach (_property ${ARGN}) if ("${_property}" MATCHES "") @@ -309,8 +314,8 @@ function (cotire_resolve_config_properites _configurations _propertiesVar) set (${_propertiesVar} ${_properties} PARENT_SCOPE) endfunction() -function (cotire_copy_set_properites _configurations _type _source _target) - cotire_resolve_config_properites("${_configurations}" _properties ${ARGN}) +function (cotire_copy_set_properties _configurations _type _source _target) + cotire_resolve_config_properties("${_configurations}" _properties ${ARGN}) foreach (_property ${_properties}) get_property(_isSet ${_type} ${_source} PROPERTY ${_property} SET) if (_isSet) @@ -320,13 +325,18 @@ function (cotire_copy_set_properites _configurations _type _source _target) endforeach() endfunction() -function (cotire_get_target_usage_requirements _target _targetRequirementsVar) +function (cotire_get_target_usage_requirements _target _config _targetRequirementsVar) set (_targetRequirements "") get_target_property(_librariesToProcess ${_target} LINK_LIBRARIES) while (_librariesToProcess) # remove from head list (GET _librariesToProcess 0 _library) list (REMOVE_AT _librariesToProcess 0) + if (_library MATCHES "^\\$<\\$:([A-Za-z0-9_:-]+)>$") + set (_library "${CMAKE_MATCH_1}") + elseif (_config STREQUAL "None" AND _library MATCHES "^\\$<\\$:([A-Za-z0-9_:-]+)>$") + set (_library "${CMAKE_MATCH_1}") + endif() if (TARGET ${_library}) list (FIND _targetRequirements ${_library} _index) if (_index LESS 0) @@ -441,7 +451,7 @@ function (cotire_get_target_compile_flags _config _language _target _flagsVar) # interface compile options from linked library targets if (_target) set (_linkedTargets "") - cotire_get_target_usage_requirements(${_target} _linkedTargets) + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) foreach (_linkedTarget ${_linkedTargets}) get_target_property(_targetOptions ${_linkedTarget} INTERFACE_COMPILE_OPTIONS) if (_targetOptions) @@ -450,22 +460,21 @@ function (cotire_get_target_compile_flags _config _language _target _flagsVar) endforeach() endif() # handle language standard properties - if (_target) - get_target_property(_targetLanguageStandard ${_target} ${_language}_STANDARD) - get_target_property(_targetLanguageExtensions ${_target} ${_language}_EXTENSIONS) - get_target_property(_targetLanguageStandardRequired ${_target} ${_language}_STANDARD_REQUIRED) - if (_targetLanguageExtensions) - if (CMAKE_${_language}${_targetLanguageExtensions}_EXTENSION_COMPILE_OPTION) - list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageExtensions}_EXTENSION_COMPILE_OPTION}") - endif() - elseif (_targetLanguageStandard) - if (_targetLanguageStandardRequired) - if (CMAKE_${_language}${_targetLanguageStandard}_STANDARD_COMPILE_OPTION) - list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_STANDARD_COMPILE_OPTION}") + if (CMAKE_${_language}_STANDARD_DEFAULT) + # used compiler supports language standard levels + if (_target) + get_target_property(_targetLanguageStandard ${_target} ${_language}_STANDARD) + if (_targetLanguageStandard) + set (_type "EXTENSION") + get_property(_isSet TARGET ${_target} PROPERTY ${_language}_EXTENSIONS SET) + if (_isSet) + get_target_property(_targetUseLanguageExtensions ${_target} ${_language}_EXTENSIONS) + if (NOT _targetUseLanguageExtensions) + set (_type "STANDARD") + endif() endif() - else() - if (CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION) - list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_EXTENSION_COMPILE_OPTION}") + if (CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION) + list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION}") endif() endif() endif() @@ -574,7 +583,7 @@ function (cotire_get_target_include_directories _config _language _target _inclu # interface include directories from linked library targets if (_target) set (_linkedTargets "") - cotire_get_target_usage_requirements(${_target} _linkedTargets) + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) foreach (_linkedTarget ${_linkedTargets}) get_target_property(_linkedTargetType ${_linkedTarget} TYPE) if (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE AND NOT CMAKE_VERSION VERSION_LESS "3.4.0" AND @@ -628,6 +637,25 @@ function (cotire_get_target_include_directories _config _language _target _inclu if (CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES) list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES}) endif() + if (WIN32 AND NOT MINGW) + # convert Windows paths in include directories to CMake paths + if (_includeDirs) + set (_paths "") + foreach (_dir ${_includeDirs}) + file (TO_CMAKE_PATH "${_dir}" _path) + list (APPEND _paths "${_path}") + endforeach() + set (_includeDirs ${_paths}) + endif() + if (_systemIncludeDirs) + set (_paths "") + foreach (_dir ${_systemIncludeDirs}) + file (TO_CMAKE_PATH "${_dir}" _path) + list (APPEND _paths "${_path}") + endforeach() + set (_systemIncludeDirs ${_paths}) + endif() + endif() if (COTIRE_DEBUG AND _includeDirs) message (STATUS "Target ${_target} include dirs: ${_includeDirs}") endif() @@ -685,7 +713,7 @@ function (cotire_get_target_compile_definitions _config _language _target _defin endif() # interface compile definitions from linked library targets set (_linkedTargets "") - cotire_get_target_usage_requirements(${_target} _linkedTargets) + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) foreach (_linkedTarget ${_linkedTargets}) get_target_property(_definitions ${_linkedTarget} INTERFACE_COMPILE_DEFINITIONS) if (_definitions) @@ -841,6 +869,9 @@ macro (cotire_set_cmd_to_prologue _cmdVar) list (APPEND ${_cmdVar} "--warn-uninitialized") endif() list (APPEND ${_cmdVar} "-DCOTIRE_BUILD_TYPE:STRING=$") + if (XCODE) + list (APPEND ${_cmdVar} "-DXCODE:BOOL=TRUE") + endif() if (COTIRE_VERBOSE) list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=ON") elseif("${CMAKE_GENERATOR}" MATCHES "Makefiles") @@ -884,16 +915,16 @@ function (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemInclu foreach (_include ${_includeDirs}) if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") file (TO_NATIVE_PATH "${_include}" _include) - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") else() set (_index -1) if ("${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" MATCHES ".+") list (FIND ${_systemIncludesVar} "${_include}" _index) endif() if (_index GREATER -1) - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") else() - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") endif() endif() endforeach() @@ -1184,7 +1215,7 @@ endfunction() function (cotire_scan_includes _includesVar) set(_options "") - set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_VERSION LANGUAGE UNPARSED_LINES) + set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_VERSION LANGUAGE UNPARSED_LINES SCAN_RESULT) set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH COMPILER_LAUNCHER) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) @@ -1257,6 +1288,9 @@ function (cotire_scan_includes _includesVar) if (_option_UNPARSED_LINES) set (${_option_UNPARSED_LINES} ${_unparsedLines} PARENT_SCOPE) endif() + if (_option_SCAN_RESULT) + set (${_option_SCAN_RESULT} ${_result} PARENT_SCOPE) + endif() endfunction() macro (cotire_append_undefs _contentsVar) @@ -1444,12 +1478,13 @@ function (cotire_generate_prefix_header _prefixFile) INCLUDE_PATH ${_option_INCLUDE_PATH} IGNORE_EXTENSIONS ${_option_IGNORE_EXTENSIONS} INCLUDE_PRIORITY_PATH ${_option_INCLUDE_PRIORITY_PATH} - UNPARSED_LINES _unparsedLines) + UNPARSED_LINES _unparsedLines + SCAN_RESULT _scanResult) cotire_generate_unity_source("${_prefixFile}" PROLOGUE ${_prologue} EPILOGUE ${_epilogue} LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders}) set (_unparsedLinesFile "${_prefixFile}.log") if (_unparsedLines) - if (COTIRE_VERBOSE OR NOT _selectedHeaders) + if (COTIRE_VERBOSE OR _scanResult OR NOT _selectedHeaders) list (LENGTH _unparsedLines _skippedLineCount) message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesFile}") endif() @@ -1635,6 +1670,10 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio get_filename_component(_pchName "${_pchFile}" NAME) set (_xLanguage_C "c-header") set (_xLanguage_CXX "c++-header") + set (_pchSuppressMessages FALSE) + if ("${CMAKE_${_language}_FLAGS}" MATCHES ".*-Wno-pch-messages.*") + set(_pchSuppressMessages TRUE) + endif() if (_flags) # append to list if ("${_language}" STREQUAL "CXX") @@ -1642,13 +1681,17 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio endif() list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-create" "${_pchName}" "-fsyntax-only" "${_hostFile}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - list (APPEND _flags "-Wpch-messages") + if (NOT _pchSuppressMessages) + list (APPEND _flags "-Wpch-messages") + endif() endif() else() # return as a flag string set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-create \"${_pchName}\"") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - set (_flags "${_flags} -Wpch-messages") + if (NOT _pchSuppressMessages) + set (_flags "${_flags} -Wpch-messages") + endif() endif() endif() endif() @@ -1759,17 +1802,25 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV if (_pchFile) get_filename_component(_pchDir "${_pchFile}" DIRECTORY) get_filename_component(_pchName "${_pchFile}" NAME) + set (_pchSuppressMessages FALSE) + if ("${CMAKE_${_language}_FLAGS}" MATCHES ".*-Wno-pch-messages.*") + set(_pchSuppressMessages TRUE) + endif() if (_flags) # append to list list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - list (APPEND _flags "-Wpch-messages") + if (NOT _pchSuppressMessages) + list (APPEND _flags "-Wpch-messages") + endif() endif() else() # return as a flag string set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\"") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - set (_flags "${_flags} -Wpch-messages") + if (NOT _pchSuppressMessages) + set (_flags "${_flags} -Wpch-messages") + endif() endif() endif() else() @@ -1817,6 +1868,14 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) if (_option_COMPILER_ID MATCHES "MSVC") # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) + elseif (_option_COMPILER_ID MATCHES "GNU|Clang") + if (_option_COMPILER_LAUNCHER MATCHES "ccache" OR + _option_COMPILER_EXECUTABLE MATCHES "ccache") + # Newer versions of Clang and GCC seem to embed a compilation timestamp into the precompiled header binary, + # which results in "file has been modified since the precompiled header was built" errors if ccache is used. + # We work around the problem by disabling ccache upon pre-compiling the prefix header. + set (ENV{CCACHE_DISABLE} "true") + endif() endif() execute_process( COMMAND ${_cmd} @@ -1856,10 +1915,31 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) endif() get_target_property(_launcher ${_target} ${_language}_COMPILER_LAUNCHER) if (CMAKE_${_language}_COMPILER MATCHES "ccache" OR _launcher MATCHES "ccache") - if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros|pch_defines") - set (${_msgVar} - "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." - PARENT_SCOPE) + if (DEFINED ENV{CCACHE_SLOPPINESS}) + if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "pch_defines" OR NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") + set (${_msgVar} + "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." + PARENT_SCOPE) + endif() + else() + if (_launcher MATCHES "ccache") + get_filename_component(_ccacheExe "${_launcher}" REALPATH) + else() + get_filename_component(_ccacheExe "${CMAKE_${_language}_COMPILER}" REALPATH) + endif() + execute_process( + COMMAND "${_ccacheExe}" "--print-config" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _ccacheConfig OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + if (_result OR NOT + _ccacheConfig MATCHES "sloppiness.*=.*time_macros" OR NOT + _ccacheConfig MATCHES "sloppiness.*=.*pch_defines") + set (${_msgVar} + "ccache requires configuration setting \"sloppiness\" to be set to \"pch_defines,time_macros\"." + PARENT_SCOPE) + endif() endif() endif() if (APPLE) @@ -2148,7 +2228,7 @@ function (cotire_generate_target_script _language _configurations _target _targe XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER_VERSION CMAKE_${_language}_COMPILER_LAUNCHER CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 - CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_FLAG_${_language}_SEP + CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_FLAG_SEP_${_language} CMAKE_INCLUDE_SYSTEM_FLAG_${_language} CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG @@ -2206,14 +2286,18 @@ function (cotire_setup_pch_file_compilation _language _target _targetScript _pre else() file (RELATIVE_PATH _pchFileLogPath "${CMAKE_BINARY_DIR}" "${_pchFile}") endif() + # make precompiled header compilation depend on the actual compiler executable used to force + # re-compilation when the compiler executable is updated. This prevents "created by a different GCC executable" + # warnings when the precompiled header is included. + get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" ABSOLUTE) if (COTIRE_DEBUG) - message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} IMPLICIT_DEPENDS ${_language} ${_prefixFile}") + message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} ${_realCompilerExe} IMPLICIT_DEPENDS ${_language} ${_prefixFile}") endif() set_property (SOURCE "${_pchFile}" PROPERTY GENERATED TRUE) add_custom_command( OUTPUT "${_pchFile}" COMMAND ${_cmds} - DEPENDS "${_prefixFile}" + DEPENDS "${_prefixFile}" "${_realCompilerExe}" IMPLICIT_DEPENDS ${_language} "${_prefixFile}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Building ${_language} precompiled header ${_pchFileLogPath}" @@ -2445,8 +2529,12 @@ function (cotire_setup_prefix_generation_command _language _target _targetScript cotire_set_cmd_to_prologue(_prefixCmd) list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "prefix" "${_targetScript}" "${_prefixFile}" ${_unityFiles}) set_property (SOURCE "${_prefixFile}" PROPERTY GENERATED TRUE) + # make prefix header generation depend on the actual compiler executable used to force + # re-generation when the compiler executable is updated. This prevents "file not found" + # errors for compiler version specific system header files. + get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" ABSOLUTE) if (COTIRE_DEBUG) - message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_unityFile} ${_dependencySources}") + message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_unityFile} ${_dependencySources} ${_realCompilerExe}") endif() if (MSVC_IDE) file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileLogPath) @@ -2478,7 +2566,7 @@ function (cotire_setup_prefix_generation_command _language _target _targetScript add_custom_command( OUTPUT "${_prefixFile}" "${_prefixFile}.log" COMMAND ${_prefixCmd} - DEPENDS ${_unityFiles} ${_dependencySources} + DEPENDS ${_unityFiles} ${_dependencySources} "${_realCompilerExe}" COMMENT "${_comment}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM) @@ -2639,10 +2727,12 @@ function (cotire_choose_target_languages _target _targetLanguagesVar _wholeTarge set (${_targetLanguagesVar} "" PARENT_SCOPE) return() endif() - if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$" AND NOT "${CMAKE_${_language}_COMPILER_ID}" STREQUAL "") - cotire_check_precompiled_header_support("${_language}" "${_target}" _disableMsg) - if (_disableMsg) - set (_targetUsePCH FALSE) + if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$" AND DEFINED CMAKE_${_language}_COMPILER_ID) + if (CMAKE_${_language}_COMPILER_ID) + cotire_check_precompiled_header_support("${_language}" "${_target}" _disableMsg) + if (_disableMsg) + set (_targetUsePCH FALSE) + endif() endif() endif() set (_sourceFiles "") @@ -2857,6 +2947,16 @@ function (cotire_setup_pch_target _languages _configurations _target) endif() endfunction() +function (cotire_filter_object_libraries _target _objectLibrariesVar) + set (_objectLibraries "") + foreach (_source ${ARGN}) + if (_source MATCHES "^\\$$") + list (APPEND _objectLibraries "${_source}") + endif() + endforeach() + set (${_objectLibrariesVar} ${_objectLibraries} PARENT_SCOPE) +endfunction() + function (cotire_collect_unity_target_sources _target _languages _unityTargetSourcesVar) get_target_property(_targetSourceFiles ${_target} SOURCES) set (_unityTargetSources ${_targetSourceFiles}) @@ -2875,6 +2975,15 @@ function (cotire_collect_unity_target_sources _target _languages _unityTargetSou list (APPEND _unityTargetSources ${_unityFiles}) endif() endforeach() + get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT) + if ("${_linkLibrariesStrategy}" MATCHES "^COPY_UNITY$") + cotire_filter_object_libraries(${_target} _objectLibraries ${_targetSourceFiles}) + if (_objectLibraries) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityObjectLibraries ${_objectLibraries}) + list (REMOVE_ITEM _unityTargetSources ${_objectLibraries}) + list (APPEND _unityTargetSources ${_unityObjectLibraries}) + endif() + endif() set (${_unityTargetSourcesVar} ${_unityTargetSources} PARENT_SCOPE) endfunction() @@ -2917,8 +3026,13 @@ function (cotire_setup_unity_build_target _languages _configurations _target) if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) # if the original target sources are subject to CMake's automatic Qt processing, # also include implicitly generated _automoc.cpp file - list (APPEND _unityTargetSources "${_target}_automoc.cpp") - set_property (SOURCE "${_target}_automoc.cpp" PROPERTY GENERATED TRUE) + if (CMAKE_VERSION VERSION_LESS "3.8.0") + list (APPEND _unityTargetSources "${_target}_automoc.cpp") + set_property (SOURCE "${_target}_automoc.cpp" PROPERTY GENERATED TRUE) + else() + list (APPEND _unityTargetSources "${_target}_autogen/moc_compilation.cpp") + set_property (SOURCE "${_target}_autogen/moc_compilation.cpp" PROPERTY GENERATED TRUE) + endif() endif() # prevent AUTOMOC, AUTOUIC and AUTORCC properties from being set when the unity target is created set (CMAKE_AUTOMOC OFF) @@ -2933,9 +3047,20 @@ function (cotire_setup_unity_build_target _languages _configurations _target) else() add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) endif() - if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) - # depend on the original target's implicity generated _automoc target - add_dependencies(${_unityTargetName} ${_target}_automoc) + if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + # depend on original target's automoc target, if it exists + if (TARGET ${_target}_automoc) + add_dependencies(${_unityTargetName} ${_target}_automoc) + endif() + else() + if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) + # depend on the original target's implicity generated _automoc target + if (CMAKE_VERSION VERSION_LESS "3.8.0") + add_dependencies(${_unityTargetName} ${_target}_automoc) + else() + add_dependencies(${_unityTargetName} ${_target}_autogen) + endif() + endif() endif() # copy output location properties set (_outputDirProperties @@ -2948,8 +3073,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) set (_outputDir "${COTIRE_UNITY_OUTPUT_DIRECTORY}") else() # append relative COTIRE_UNITY_OUTPUT_DIRECTORY to target's actual output directory - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) - cotire_resolve_config_properites("${_configurations}" _properties ${_outputDirProperties}) + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) + cotire_resolve_config_properties("${_configurations}" _properties ${_outputDirProperties}) foreach (_property ${_properties}) get_property(_outputDir TARGET ${_target} PROPERTY ${_property}) if (_outputDir) @@ -2969,11 +3094,11 @@ function (cotire_setup_unity_build_target _languages _configurations _target) RUNTIME_OUTPUT_DIRECTORY "${_outputDir}") endif() else() - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) endif() # copy output name - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_ LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_ OUTPUT_NAME OUTPUT_NAME_ @@ -2981,7 +3106,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) PREFIX _POSTFIX SUFFIX IMPORT_PREFIX IMPORT_SUFFIX) # copy compile stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPILE_DEFINITIONS COMPILE_DEFINITIONS_ COMPILE_FLAGS COMPILE_OPTIONS Fortran_FORMAT Fortran_MODULE_DIRECTORY @@ -2990,14 +3115,15 @@ function (cotire_setup_unity_build_target _languages _configurations _target) POSITION_INDEPENDENT_CODE C_COMPILER_LAUNCHER CXX_COMPILER_LAUNCHER C_INCLUDE_WHAT_YOU_USE CXX_INCLUDE_WHAT_YOU_USE - C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN) + C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN + C_CLANG_TIDY CXX_CLANG_TIDY) # copy compile features - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED COMPILE_FEATURES) # copy interface stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN COMPATIBLE_INTERFACE_STRING INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_FEATURES INTERFACE_COMPILE_OPTIONS @@ -3005,7 +3131,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES INTERFACE_AUTOUIC_OPTIONS NO_SYSTEM_FROM_IMPORTED) # copy link stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED LINK_FLAGS LINK_FLAGS_ @@ -3013,18 +3139,19 @@ function (cotire_setup_unity_build_target _languages _configurations _target) LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_ LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_ - NO_SONAME SOVERSION VERSION) + NO_SONAME SOVERSION VERSION + LINK_WHAT_YOU_USE BUILD_RPATH) # copy cmake stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) # copy Apple platform specific stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} BUNDLE BUNDLE_EXTENSION FRAMEWORK FRAMEWORK_VERSION INSTALL_NAME_DIR MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE XCTEST - IOS_INSTALL_COMBINED) + IOS_INSTALL_COMBINED XCODE_EXPLICIT_FILE_TYPE XCODE_PRODUCT_TYPE) # copy Windows platform specific stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} GNUtoMS COMPILE_PDB_NAME COMPILE_PDB_NAME_ COMPILE_PDB_OUTPUT_DIRECTORY COMPILE_PDB_OUTPUT_DIRECTORY_ @@ -3036,9 +3163,11 @@ function (cotire_setup_unity_build_target _languages _configurations _target) VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION VS_WINRT_COMPONENT VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES - WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS) + WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS + DEPLOYMENT_REMOTE_DIRECTORY VS_CONFIGURATION_TYPE + VS_SDK_REFERENCES VS_USER_PROPS VS_DEBUGGER_WORKING_DIRECTORY) # copy Android platform specific stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ANDROID_API ANDROID_API_MIN ANDROID_GUI ANDROID_ANT_ADDITIONAL_OPTIONS ANDROID_ARCH ANDROID_ASSETS_DIRECTORIES ANDROID_JAR_DEPENDENCIES ANDROID_JAR_DIRECTORIES ANDROID_JAVA_SOURCE_DIR @@ -3151,9 +3280,15 @@ function (cotire_map_libraries _strategy _mappedLibrariesVar) if (_library MATCHES "^\\$$") set (_libraryName "${CMAKE_MATCH_1}") set (_linkOnly TRUE) + set (_objectLibrary FALSE) + elseif (_library MATCHES "^\\$$") + set (_libraryName "${CMAKE_MATCH_1}") + set (_linkOnly FALSE) + set (_objectLibrary TRUE) else() set (_libraryName "${_library}") set (_linkOnly FALSE) + set (_objectLibrary FALSE) endif() if ("${_strategy}" MATCHES "COPY_UNITY") cotire_is_target_supported(${_libraryName} _isSupported) @@ -3163,6 +3298,8 @@ function (cotire_map_libraries _strategy _mappedLibrariesVar) if (TARGET "${_libraryUnityTargetName}") if (_linkOnly) list (APPEND _mappedLibraries "$") + elseif (_objectLibrary) + list (APPEND _mappedLibraries "$") else() list (APPEND _mappedLibraries "${_libraryUnityTargetName}") endif() diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index eb5805662..9365d5faa 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1,64 +1,65 @@ -project(vcmilauncher) -cmake_minimum_required(VERSION 2.8.7) - +# Detailed information about CMake compatibility available on Qt website +# https://doc.qt.io/qt-5/cmake-manual.html include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${ZLIB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) -include_directories(${SDL_INCLUDE_DIR}) +include_directories(${SDL2_INCLUDE_DIR}) set(launcher_modmanager_SRCS - modManager/cdownloadmanager_moc.cpp - modManager/cmodlist.cpp - modManager/cmodlistmodel_moc.cpp - modManager/cmodlistview_moc.cpp - modManager/cmodmanager.cpp - modManager/imageviewer_moc.cpp + modManager/cdownloadmanager_moc.cpp + modManager/cmodlist.cpp + modManager/cmodlistmodel_moc.cpp + modManager/cmodlistview_moc.cpp + modManager/cmodmanager.cpp + modManager/imageviewer_moc.cpp ) set(launcher_modmanager_HEADERS - modManager/cdownloadmanager_moc.h - modManager/cmodlist.h - modManager/cmodlistmodel_moc.h - modManager/cmodlistview_moc.h - modManager/cmodmanager.h - modManager/imageviewer_moc.h + modManager/cdownloadmanager_moc.h + modManager/cmodlist.h + modManager/cmodlistmodel_moc.h + modManager/cmodlistview_moc.h + modManager/cmodmanager.h + modManager/imageviewer_moc.h ) set(launcher_settingsview_SRCS - settingsView/csettingsview_moc.cpp + settingsView/csettingsview_moc.cpp ) set(launcher_settingsview_HEADERS - settingsView/csettingsview_moc.h + settingsView/csettingsview_moc.h ) set(launcher_SRCS - StdInc.cpp - ${launcher_modmanager_SRCS} - ${launcher_settingsview_SRCS} - main.cpp - mainwindow_moc.cpp - launcherdirs.cpp - jsonutils.cpp - sdldisplayquery.cpp + StdInc.cpp + ${launcher_modmanager_SRCS} + ${launcher_settingsview_SRCS} + main.cpp + mainwindow_moc.cpp + launcherdirs.cpp + jsonutils.cpp + sdldisplayquery.cpp ) set(launcher_HEADERS - StdInc.h - ${launcher_modmanager_HEADERS} - ${launcher_settingsview_HEADERS} - mainwindow_moc.h - launcherdirs.h - jsonutils.h - sdldisplayquery.h + StdInc.h + ${launcher_modmanager_HEADERS} + ${launcher_settingsview_HEADERS} + mainwindow_moc.h + launcherdirs.h + jsonutils.h + sdldisplayquery.h ) set(launcher_FORMS - modManager/cmodlistview_moc.ui - modManager/imageviewer_moc.ui - settingsView/csettingsview_moc.ui - mainwindow_moc.ui + modManager/cmodlistview_moc.ui + modManager/imageviewer_moc.ui + settingsView/csettingsview_moc.ui + mainwindow_moc.ui ) +assign_source_group(${launcher_SRCS} ${launcher_HEADERS} VCMI_launcher.rc) + # Tell CMake to run moc when necessary: set(CMAKE_AUTOMOC ON) @@ -66,40 +67,59 @@ set(CMAKE_AUTOMOC ON) # to always look for includes there: set(CMAKE_INCLUDE_CURRENT_DIR ON) -# We need add -DQT_WIDGETS_LIB when using QtWidgets in Qt 5. -add_definitions(${Qt5Widgets_DEFINITIONS}) -add_definitions(${Qt5Network_DEFINITIONS}) - -# Executables fail to build with Qt 5 in the default configuration -# without -fPIE. We add that here. -set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS}") +if("${CMAKE_VERSION}" VERSION_LESS 2.8.12) + # Executables fail to build with Qt 5 in the default configuration + # without -fPIE. We add that here. + set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS}") +endif() qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS}) if(WIN32) - add_executable(vcmilauncher WIN32 ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} VCMI_launcher.rc) - set_target_properties(vcmilauncher PROPERTIES OUTPUT_NAME VCMI_launcher) -else() - add_executable(vcmilauncher ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS}) + set(launcher_ICON VCMI_launcher.rc) endif() -if(MSVC) - # Fix _WinMain@16 linking error - target_link_libraries(vcmilauncher vcmi ${Qt5Core_QTMAIN_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${SDL_LIBRARY}) -else() - # The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore - target_link_libraries(vcmilauncher vcmi ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${SDL_LIBRARY}) +add_executable(vcmilauncher WIN32 ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON}) + +if(WIN32) + set_target_properties(vcmilauncher + PROPERTIES + OUTPUT_NAME "VCMI_launcher" + PROJECT_LABEL "VCMI_launcher" + ) + + # FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2 + # So far I tried: + # - cmake_minimum_required set to 2.8.11 globally and in this file + # - cmake_policy in all possible places + # - used NO_POLICY_SCOPE to make sure no other parts reset policies + # Still nothing worked, warning kept appearing and WinMain didn't link automatically + target_link_libraries(vcmilauncher Qt5::WinMain) endif() +if(APPLE) + # This makes Xcode project prettier by moving vcmilauncher_autogen directory into vcmiclient subfolder + set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmilauncher) +endif() + +target_link_libraries(vcmilauncher vcmi Qt5::Widgets Qt5::Network ${SDL2_LIBRARY}) + vcmi_set_output_dir(vcmilauncher "") # temporary(?) disabled - generation of PCH takes too much time since cotire is trying to collect all Qt headers #set_target_properties(vcmilauncher PROPERTIES ${PCH_PROPERTIES}) #cotire(vcmilauncher) -if (NOT APPLE) # Already inside bundle - install(TARGETS vcmilauncher DESTINATION ${BIN_DIR}) - # copy whole directory but .svn control files - install(DIRECTORY icons DESTINATION ${DATA_DIR}/launcher PATTERN ".svn" EXCLUDE) -endif() +# 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/launcher/VCMI_launcher.ico b/launcher/VCMI_launcher.ico index 449296f49..40818c464 100644 Binary files a/launcher/VCMI_launcher.ico and b/launcher/VCMI_launcher.ico differ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 8a481a6d0..14ad6253d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,8 +1,5 @@ -project(libvcmi) -cmake_minimum_required(VERSION 2.6) - include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/lib) -include_directories(${Boost_INCLUDE_DIRS} ${SDL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) +include_directories(${Boost_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) set(lib_SRCS StdInc.cpp @@ -288,16 +285,21 @@ set(lib_HEADERS VCMI_Lib.h ) +assign_source_group(${lib_SRCS} ${lib_HEADERS}) + add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS}) -set_target_properties(vcmi PROPERTIES XCODE_ATTRIBUTE_LD_DYLIB_INSTALL_NAME "@rpath/libvcmi.dylib") set_target_properties(vcmi PROPERTIES COMPILE_DEFINITIONS "VCMI_DLL=1") -target_link_libraries(vcmi ${MINIZIP_LIBRARIES} ${Boost_LIBRARIES} ${SDL_LIBRARY} ${ZLIB_LIBRARIES} ${SYSTEM_LIBS}) +target_link_libraries(vcmi ${MINIZIP_LIBRARIES} ${Boost_LIBRARIES} ${SDL2_LIBRARY} ${ZLIB_LIBRARIES} ${SYSTEM_LIBS}) if(WIN32) - set_target_properties(vcmi PROPERTIES OUTPUT_NAME VCMI_lib) + set_target_properties(vcmi + PROPERTIES + OUTPUT_NAME "VCMI_lib" + PROJECT_LABEL "VCMI_lib" + ) endif() -if (ANDROID) +if(ANDROID) return() endif() @@ -306,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..3fde5079a 100644 --- a/lib/VCMIDirs.cpp +++ b/lib/VCMIDirs.cpp @@ -452,7 +452,17 @@ bfs::path VCMIDirsOSX::userConfigPath() const { return userDataPath() / "config" std::vector VCMIDirsOSX::dataPaths() const { - return std::vector(1, "../Data"); + std::vector ret; + //FIXME: need some proper codepath for detecting running from build output directory + if(bfs::exists("config") && bfs::exists("Mods") && bfs::exists("vcmiserver")) + { + ret.push_back("."); + } + else + { + ret.push_back("../Resources/Data"); + } + return ret; } bfs::path VCMIDirsOSX::libraryPath() const { return "."; } @@ -521,7 +531,13 @@ std::vector VCMIDirsXDG::dataPaths() const const char* tempResult; ret.push_back(M_DATA_DIR); - if ((tempResult = getenv("XDG_DATA_DIRS")) != nullptr) + //FIXME: need some proper codepath for detecting running from build output directory + if(bfs::exists("config") && bfs::exists("Mods") && bfs::exists("vcmiserver")) + { + //For now we'll disable usage of system directories when VCMI running from bin directory + ret.push_back("."); + } + else if((tempResult = getenv("XDG_DATA_DIRS")) != nullptr) { std::string dataDirsEnv = tempResult; std::vector dataDirs; diff --git a/lib/minizip/CMakeLists.txt b/lib/minizip/CMakeLists.txt index 65696bac2..f2d966af1 100644 --- a/lib/minizip/CMakeLists.txt +++ b/lib/minizip/CMakeLists.txt @@ -1,5 +1,4 @@ project(minizip) -cmake_minimum_required(VERSION 2.6) include_directories(${ZLIB_INCLUDE_DIR}) @@ -14,25 +13,10 @@ set(lib_SRCS add_library(minizip SHARED ${lib_SRCS}) if(MSVC) set_target_properties(minizip PROPERTIES COMPILE_DEFINITIONS "MINIZIP_DLL;ZLIB_DLL;ZLIB_INTERNAL") -elseif(APPLE) - set_target_properties(minizip PROPERTIES XCODE_ATTRIBUTE_LD_DYLIB_INSTALL_NAME "@rpath/libminizip.dylib") endif() -# multi-config builds (e.g. msvc) -foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGUPPERCASE) - set_target_properties(minizip PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/${OUTPUTCONFIG}/lib) - set_target_properties(minizip PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/${OUTPUTCONFIG}/lib) - set_target_properties(minizip PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/${OUTPUTCONFIG}/lib) -endforeach() - -# generic no-config case (e.g. with mingw) -set_target_properties(minizip PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/lib) -set_target_properties(minizip PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/lib) -set_target_properties(minizip PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/lib) +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..845cb7d59 --- /dev/null +++ b/osx/CMakeLists.txt @@ -0,0 +1,47 @@ +# 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) + +# This will likely only work for Vcpkg +if(WIN32) + if(ENABLE_LAUNCHER) + # Temporary ugly fix for Qt deployment since windeployqt broken in Vcpkg + install(CODE " + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/\${BUILD_TYPE}/bearer \${CMAKE_INSTALL_PREFIX}/bearer + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/\${BUILD_TYPE}/iconengines \${CMAKE_INSTALL_PREFIX}/iconengines + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/\${BUILD_TYPE}/imageformats \${CMAKE_INSTALL_PREFIX}/imageformats + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/\${BUILD_TYPE}/platforminputcontexts \${CMAKE_INSTALL_PREFIX}/platforminputcontexts + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/\${BUILD_TYPE}/platforms \${CMAKE_INSTALL_PREFIX}/platforms + ) + ") + endif() + + install(CODE " + if(\"\${BUILD_TYPE}\" STREQUAL \"Debug\") + set(dirs \"${CMAKE_PREFIX_PATH}/debug/bin/\") + else() + set(dirs \"${CMAKE_PREFIX_PATH}/bin/\") + endif() + set(BU_CHMOD_BUNDLE_ITEMS ON) + include(BundleUtilities) + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/VCMI_Client.exe\" \"\" \"\${dirs}\") + + " COMPONENT Runtime) +endif(WIN32) diff --git a/osx/Info.plist.in b/osx/Info.plist.in new file mode 100644 index 000000000..23e9cd06a --- /dev/null +++ b/osx/Info.plist.in @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleGetInfoString + ${MACOSX_BUNDLE_INFO_STRING} + CFBundleIconFile + ${MACOSX_BUNDLE_ICON_FILE} + CFBundleIdentifier + ${MACOSX_BUNDLE_GUI_IDENTIFIER} + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleName + ${MACOSX_BUNDLE_BUNDLE_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleVersion + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CSResourcesFileMapped + + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + NSPrincipalClass + NSApplication + NSHighResolutionCapable + True + + diff --git a/osx/download_dependencies.sh b/osx/download_dependencies.sh deleted file mode 100644 index baa8272fe..000000000 --- a/osx/download_dependencies.sh +++ /dev/null @@ -1,15 +0,0 @@ -if [ -f ../.osx_dependencies_installed ]; -then - echo "OS X prebuilt dependencies are already installled" -else - # Download and unpack OS X prebuilt dependencies - curl -o ../xcode-pack.zip -L http://download.vcmi.eu/xcode-pack.zip - unzip ../xcode-pack.zip -d ../ - rm -rf ../__MACOSX - - # Build vcmibuilder - xcodebuild -project osx/osx-vcmibuilder/vcmibuilder.xcodeproj/ -configuration Release - mv osx/osx-vcmibuilder/build/Release/vcmibuilder.app osx/vcmibuilder.app - - touch ../.osx_dependencies_installed -fi \ No newline at end of file diff --git a/osx/osx-vcmibuilder/innoextract b/osx/osx-vcmibuilder/innoextract deleted file mode 100755 index 60fdd7515..000000000 Binary files a/osx/osx-vcmibuilder/innoextract and /dev/null differ diff --git a/osx/osx-vcmibuilder/unshield b/osx/osx-vcmibuilder/unshield deleted file mode 100755 index 124ff27fc..000000000 Binary files a/osx/osx-vcmibuilder/unshield and /dev/null differ diff --git a/osx/osx-vcmibuilder/vcmibuilder.icns b/osx/osx-vcmibuilder/vcmibuilder.icns deleted file mode 100644 index a660e31c5..000000000 Binary files a/osx/osx-vcmibuilder/vcmibuilder.icns and /dev/null differ diff --git a/osx/osx-vcmibuilder/vcmibuilder.xcodeproj/project.pbxproj b/osx/osx-vcmibuilder/vcmibuilder.xcodeproj/project.pbxproj deleted file mode 100644 index adfa1df4d..000000000 --- a/osx/osx-vcmibuilder/vcmibuilder.xcodeproj/project.pbxproj +++ /dev/null @@ -1,307 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - A8467DFF16760A4E00A9F095 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A8467DFE16760A4E00A9F095 /* Cocoa.framework */; }; - A8467E0916760A4E00A9F095 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A8467E0716760A4E00A9F095 /* InfoPlist.strings */; }; - A8467E0B16760A4E00A9F095 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A8467E0A16760A4E00A9F095 /* main.m */; }; - A8467E1216760A4E00A9F095 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A8467E1116760A4E00A9F095 /* AppDelegate.m */; }; - A8467E1516760A4E00A9F095 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = A8467E1316760A4E00A9F095 /* MainMenu.xib */; }; - A866001516760C5B00DBFB19 /* vcmibuilder.icns in Resources */ = {isa = PBXBuildFile; fileRef = A866001416760C5B00DBFB19 /* vcmibuilder.icns */; }; - A8F36836167632DC0009832A /* innoextract in Resources */ = {isa = PBXBuildFile; fileRef = A8F36834167632DC0009832A /* innoextract */; }; - A8F36837167632DC0009832A /* unshield in Resources */ = {isa = PBXBuildFile; fileRef = A8F36835167632DC0009832A /* unshield */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - A8467DFA16760A4E00A9F095 /* vcmibuilder.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = vcmibuilder.app; sourceTree = BUILT_PRODUCTS_DIR; }; - A8467DFE16760A4E00A9F095 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; - A8467E0116760A4E00A9F095 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; - A8467E0216760A4E00A9F095 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; - A8467E0316760A4E00A9F095 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - A8467E0616760A4E00A9F095 /* vcmibuilder-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "vcmibuilder-Info.plist"; sourceTree = ""; }; - A8467E0816760A4E00A9F095 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - A8467E0A16760A4E00A9F095 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - A8467E0C16760A4E00A9F095 /* vcmibuilder-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "vcmibuilder-Prefix.pch"; sourceTree = ""; }; - A8467E1016760A4E00A9F095 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - A8467E1116760A4E00A9F095 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - A8467E1416760A4E00A9F095 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; - A866001416760C5B00DBFB19 /* vcmibuilder.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = vcmibuilder.icns; sourceTree = ""; }; - A8F36834167632DC0009832A /* innoextract */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = innoextract; sourceTree = ""; }; - A8F36835167632DC0009832A /* unshield */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = unshield; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - A8467DF716760A4E00A9F095 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - A8467DFF16760A4E00A9F095 /* Cocoa.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - A8467DEF16760A4E00A9F095 = { - isa = PBXGroup; - children = ( - A8F36834167632DC0009832A /* innoextract */, - A8F36835167632DC0009832A /* unshield */, - A866001416760C5B00DBFB19 /* vcmibuilder.icns */, - A8467E0416760A4E00A9F095 /* vcmibuilder */, - A8467DFD16760A4E00A9F095 /* Frameworks */, - A8467DFB16760A4E00A9F095 /* Products */, - ); - sourceTree = ""; - }; - A8467DFB16760A4E00A9F095 /* Products */ = { - isa = PBXGroup; - children = ( - A8467DFA16760A4E00A9F095 /* vcmibuilder.app */, - ); - name = Products; - sourceTree = ""; - }; - A8467DFD16760A4E00A9F095 /* Frameworks */ = { - isa = PBXGroup; - children = ( - A8467DFE16760A4E00A9F095 /* Cocoa.framework */, - A8467E0016760A4E00A9F095 /* Other Frameworks */, - ); - name = Frameworks; - sourceTree = ""; - }; - A8467E0016760A4E00A9F095 /* Other Frameworks */ = { - isa = PBXGroup; - children = ( - A8467E0116760A4E00A9F095 /* AppKit.framework */, - A8467E0216760A4E00A9F095 /* CoreData.framework */, - A8467E0316760A4E00A9F095 /* Foundation.framework */, - ); - name = "Other Frameworks"; - sourceTree = ""; - }; - A8467E0416760A4E00A9F095 /* vcmibuilder */ = { - isa = PBXGroup; - children = ( - A8467E1016760A4E00A9F095 /* AppDelegate.h */, - A8467E1116760A4E00A9F095 /* AppDelegate.m */, - A8467E1316760A4E00A9F095 /* MainMenu.xib */, - A8467E0516760A4E00A9F095 /* Supporting Files */, - ); - path = vcmibuilder; - sourceTree = ""; - }; - A8467E0516760A4E00A9F095 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - A8467E0616760A4E00A9F095 /* vcmibuilder-Info.plist */, - A8467E0716760A4E00A9F095 /* InfoPlist.strings */, - A8467E0A16760A4E00A9F095 /* main.m */, - A8467E0C16760A4E00A9F095 /* vcmibuilder-Prefix.pch */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - A8467DF916760A4E00A9F095 /* vcmibuilder */ = { - isa = PBXNativeTarget; - buildConfigurationList = A8467E1816760A4E00A9F095 /* Build configuration list for PBXNativeTarget "vcmibuilder" */; - buildPhases = ( - A8467DF616760A4E00A9F095 /* Sources */, - A8467DF716760A4E00A9F095 /* Frameworks */, - A8467DF816760A4E00A9F095 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = vcmibuilder; - productName = vcmibuilder; - productReference = A8467DFA16760A4E00A9F095 /* vcmibuilder.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - A8467DF116760A4E00A9F095 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0450; - ORGANIZATIONNAME = "Alexey Petruchik"; - }; - buildConfigurationList = A8467DF416760A4E00A9F095 /* Build configuration list for PBXProject "vcmibuilder" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = A8467DEF16760A4E00A9F095; - productRefGroup = A8467DFB16760A4E00A9F095 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - A8467DF916760A4E00A9F095 /* vcmibuilder */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - A8467DF816760A4E00A9F095 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - A8467E0916760A4E00A9F095 /* InfoPlist.strings in Resources */, - A8467E1516760A4E00A9F095 /* MainMenu.xib in Resources */, - A866001516760C5B00DBFB19 /* vcmibuilder.icns in Resources */, - A8F36836167632DC0009832A /* innoextract in Resources */, - A8F36837167632DC0009832A /* unshield in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - A8467DF616760A4E00A9F095 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - A8467E0B16760A4E00A9F095 /* main.m in Sources */, - A8467E1216760A4E00A9F095 /* AppDelegate.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - A8467E0716760A4E00A9F095 /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - A8467E0816760A4E00A9F095 /* en */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; - A8467E1316760A4E00A9F095 /* MainMenu.xib */ = { - isa = PBXVariantGroup; - children = ( - A8467E1416760A4E00A9F095 /* en */, - ); - name = MainMenu.xib; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - A8467E1616760A4E00A9F095 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_INHIBIT_ALL_WARNINGS = NO; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.7; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - }; - name = Debug; - }; - A8467E1716760A4E00A9F095 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_INHIBIT_ALL_WARNINGS = NO; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.7; - SDKROOT = macosx; - }; - name = Release; - }; - A8467E1916760A4E00A9F095 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "vcmibuilder/vcmibuilder-Prefix.pch"; - INFOPLIST_FILE = "vcmibuilder/vcmibuilder-Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = app; - }; - name = Debug; - }; - A8467E1A16760A4E00A9F095 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "vcmibuilder/vcmibuilder-Prefix.pch"; - INFOPLIST_FILE = "vcmibuilder/vcmibuilder-Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = app; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - A8467DF416760A4E00A9F095 /* Build configuration list for PBXProject "vcmibuilder" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A8467E1616760A4E00A9F095 /* Debug */, - A8467E1716760A4E00A9F095 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - A8467E1816760A4E00A9F095 /* Build configuration list for PBXNativeTarget "vcmibuilder" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A8467E1916760A4E00A9F095 /* Debug */, - A8467E1A16760A4E00A9F095 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = A8467DF116760A4E00A9F095 /* Project object */; -} diff --git a/osx/osx-vcmibuilder/vcmibuilder/AppDelegate.h b/osx/osx-vcmibuilder/vcmibuilder/AppDelegate.h deleted file mode 100644 index ebfb447f4..000000000 --- a/osx/osx-vcmibuilder/vcmibuilder/AppDelegate.h +++ /dev/null @@ -1,53 +0,0 @@ -#import - -@interface AppDelegate : NSObject -{ - NSString* outputDir; - NSString* tempDir; - NSString* dataDir; - NSString* currentArchiveName; - NSString* currentArchiveFilename; - - NSMutableArray* actions; - - int64_t bytesRecieved; - int64_t bytesExpected; - - BOOL installationCompleted; -} - -@property (strong) IBOutlet NSWindow *window; -@property (weak) IBOutlet NSButton *cd1Button; -@property (weak) IBOutlet NSTextField *cd1TextField; -@property (weak) IBOutlet NSButton *cd2Button; -@property (weak) IBOutlet NSTextField *cd2TextField; -@property (weak) IBOutlet NSProgressIndicator *progressIndicator; -@property (weak) IBOutlet NSTextField *progressLabel; -@property (weak) IBOutlet NSButton *installButton; -@property (weak) IBOutlet NSTextField *errorLabel; - -@property (strong) NSURLDownload* download; - -- (IBAction)selectCD1:(id)sender; -- (IBAction)selectCD2:(id)sender; -- (IBAction)install:(id)sender; - -- (void)selectFile:(NSArray*)fileTypes withTextField:(NSTextField*)textField; -- (void)showProgressText:(NSString*)text; -- (void)showErrorText:(NSString*)text; -- (void)showNotification:(NSString*)text; -- (void)nextAction; -- (int)runTask:(NSString*)executable withArgs:(NSArray*)args withWorkingDir:(NSString*)workingDir withPipe:(NSPipe*)pipe; - -- (void)downloadWogArchive; -- (void)unzipWogArchive; -- (void)downloadVcmiArchive; -- (void)unzipVcmiArchive; -- (void)extractGameData; -- (void)innoexctract; -- (NSString*)attachDiskImage:(NSString*)path; -- (void)unshield; -- (void)detachDiskImage:(NSString*)mountedPath; -- (void)extractionCompleted; - -@end diff --git a/osx/osx-vcmibuilder/vcmibuilder/AppDelegate.m b/osx/osx-vcmibuilder/vcmibuilder/AppDelegate.m deleted file mode 100644 index 31082c1ed..000000000 --- a/osx/osx-vcmibuilder/vcmibuilder/AppDelegate.m +++ /dev/null @@ -1,395 +0,0 @@ -#import "AppDelegate.h" - -@implementation AppDelegate - -- (void)applicationDidFinishLaunching:(NSNotification*)aNotification -{ - installationCompleted = NO; - outputDir = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/../../Data"]; - tempDir = NSTemporaryDirectory(); - - // Output to Application Support - NSArray* appSupportDirs = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]; - outputDir = [[appSupportDirs[0] path] stringByAppendingString:@"/vcmi"]; -} - -- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender -{ - return YES; -} - -- (void)download:(NSURLDownload*)download didReceiveResponse:(NSURLResponse*)response -{ - self->bytesRecieved = 0; - self->bytesExpected = [response expectedContentLength]; -} - -- (void)download:(NSURLDownload*)download didReceiveDataOfLength:(NSUInteger)length -{ - self->bytesRecieved += length; - [self showProgressText:[NSString stringWithFormat:@"Downloading %@ archive: %3.1f Mb / %3.1f Mb", self->currentArchiveName, - self->bytesRecieved / 1024.0f / 1024.0f, self->bytesExpected / 1024.0f / 1024.0f]]; -} - -- (void)download:(NSURLDownload*)download decideDestinationWithSuggestedFilename:(NSString*)filename -{ - [download setDestination:[tempDir stringByAppendingString:currentArchiveFilename] allowOverwrite:YES]; -} - -- (void)downloadDidFinish:(NSURLDownload*)download -{ - [self showProgressText:[NSString stringWithFormat:@"Downloading %@ archive: completed", self->currentArchiveName]]; - [self nextAction]; -} - -- (void)download:(NSURLDownload*)download didFailWithError:(NSError*)error -{ - [self showProgressText:[NSString stringWithFormat:@"Downloading %@ archive: failed", self->currentArchiveName]]; - [self showErrorText:[error localizedDescription]]; -} - -- (void)nextAction -{ - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - if ([actions count] > 0) { - SEL sel = NSSelectorFromString(actions[0]); - [actions removeObjectAtIndex:0]; - @try { - [self performSelector:sel]; - } - @catch (NSException* e) { - [self showErrorText:[e name]]; - } - } - }); -} - -- (int)runTask:(NSString*)executable withArgs:(NSArray*)args withWorkingDir:(NSString*)workingDir withPipe:(NSPipe*)pipe -{ - if (![executable hasPrefix:@"/usr/"]) { - executable = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:executable]; - } - - NSTask* task = [[NSTask alloc] init]; - [task setLaunchPath:executable]; - if (workingDir != nil) { - [task setCurrentDirectoryPath:workingDir]; - } - if (pipe != nil) { - [task setStandardOutput:pipe]; - } - [task setArguments:args]; - - [task launch]; - [task waitUntilExit]; - - return [task terminationStatus]; -} - -- (void)validateAction -{ - // Before starting anything run validations - if (![[NSFileManager defaultManager] fileExistsAtPath:[self.cd1TextField stringValue]]) { - return [self showErrorText:@"Please select existing file"]; - } - - // Show progress controls - [self.progressIndicator setHidden:NO]; - [self.progressIndicator startAnimation:self]; - [self showProgressText:@"Installing VCMI..."]; - - [self nextAction]; -} - -- (void)downloadWogArchive -{ - // First of all we need to download WoG archive - // Downloading should be done on main thread because of callbacks - dispatch_async(dispatch_get_main_queue(), ^{ - self->currentArchiveName = @"WoG"; - self->currentArchiveFilename = @"/wog.zip"; - NSURL* url = [NSURL URLWithString:@"https://download.vcmi.eu/WoG/wog.zip"]; - self.download = [[NSURLDownload alloc] initWithRequest:[NSURLRequest requestWithURL:url] delegate:self]; - }); -} - -- (void)unzipWogArchive -{ - // Then we unzip downloaded WoG archive - [self showProgressText:@"Unzipping WoG archive"]; - if ([self runTask:@"/usr/bin/unzip" withArgs:@[@"-qo", [tempDir stringByAppendingString:currentArchiveFilename], @"-d", outputDir] withWorkingDir:nil withPipe:nil] != 0) { - return [self showErrorText:@"Failed to unzip WoG archive"]; - } - - [self nextAction]; -} - -- (void)downloadVcmiArchive -{ - // Than we need to download VCMI archive - // Downloading should be done on main thread because of callbacks - dispatch_async(dispatch_get_main_queue(), ^{ - self->currentArchiveName = @"VCMI"; - self->currentArchiveFilename = @"/core.zip"; - NSURL* url = [NSURL URLWithString:@"https://download.vcmi.eu/core.zip"]; - self.download = [[NSURLDownload alloc] initWithRequest:[NSURLRequest requestWithURL:url] delegate:self]; - }); -} - -- (void)unzipVcmiArchive -{ - // Then we unzip downloaded VCMI archive - [self showProgressText:@"Unzipping VCMI archive"]; - if ([self runTask:@"/usr/bin/unzip" withArgs:@[@"-qo", [tempDir stringByAppendingString:currentArchiveFilename], @"-d", outputDir, @"-x", @"*.json", @"*.txt", @"*.PAL"] withWorkingDir:nil withPipe:nil] != 0) { - return [self showErrorText:@"Failed to unzip VCMI archive"]; - } - - [self nextAction]; -} - -- (void)extractGameData -{ - // Then we extract game data from provided iso files using unshield or from innosetup exe - if ([[self.cd1TextField stringValue] hasSuffix:@".exe"]) { - [self innoexctract]; - } else { - [self unshield]; - } - - [self nextAction]; -} - -- (void)innoexctract -{ - // Extraction via innoextact is pretty straightforward - [self showProgressText:@"Extracting game data using innoextract..."]; - if ([self runTask:@"/innoextract" withArgs:@[[self.cd1TextField stringValue]] withWorkingDir:tempDir withPipe:nil] != 0) { - [self showErrorText:@"Failed to exctract game data using innoextract"]; - } - - dataDir = [tempDir stringByAppendingString:@"/app"]; -} - -- (NSString*)attachDiskImage:(NSString*)path -{ - [self showProgressText:[NSString stringWithFormat:@"Mounting image \"%@\"", path]]; - - // Run hdiutil to mount specified disk image - NSPipe* pipe = [NSPipe pipe]; - if ([self runTask:@"/usr/bin/hdiutil" withArgs:@[@"attach", path] withWorkingDir:nil withPipe:pipe] != 0) { - [NSException raise:[NSString stringWithFormat:@"Failed to mount \"%@\"", path] format:nil]; - } - - // Capture hdiutil output to get mounted disk image filesystem path - NSFileHandle* file = [pipe fileHandleForReading]; - NSString* output = [[NSString alloc] initWithData:[file readDataToEndOfFile] encoding:NSUTF8StringEncoding]; - - NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:@"(/Volumes/.*)$" options:0 error:nil]; - NSTextCheckingResult* match = [regex firstMatchInString:output options:0 range:NSMakeRange(0, [output length])]; - - return [output substringWithRange:[match range]]; -} - -- (void)detachDiskImage:(NSString*)mountedPath -{ - if ([self runTask:@"/usr/bin/hdiutil" withArgs:@[@"detach", mountedPath] withWorkingDir:nil withPipe:nil] != 0) { - [NSException raise:[NSString stringWithFormat:@"Failed to unmount \"%@\"", mountedPath] format:nil]; - } -} - -- (void)unshield -{ - // In case of iso files we should mount them first - // If CD2 is not specified use the same path as for CD1 - NSString* cd1 = [self attachDiskImage:[self.cd1TextField stringValue]]; - NSString* cd2 = [[self.cd2TextField stringValue] isEqualToString:@""] ? cd1 : [self attachDiskImage:[self.cd2TextField stringValue]]; - - // Extract - [self showProgressText:@"Extracting game data using unshield..."]; - - NSArray* knownLocations = @[ - @"/_setup/data1.cab", - @"/Autorun/Setup/data1.cab" - ]; - - bool success = false; - for (NSString* location in knownLocations) { - NSString* cabLocation = [cd1 stringByAppendingString:location]; - if ([[NSFileManager defaultManager] fileExistsAtPath:cabLocation]) { - int result = [self runTask:@"/unshield" withArgs:@[@"-d", tempDir, @"x", cabLocation] withWorkingDir:tempDir withPipe:nil]; - - if (result == 0) { - success = true; - break; - } - } - } - - if (!success) { - return [self showErrorText:@"Failed to extract game data using unshield"]; - } - - NSArray* knownDataDirs = @[ - @"/Heroes3", - @"/Program_Files", - @"/Data", - ]; - - success = false; - for (NSString* knownDir in knownDataDirs) { - dataDir = [tempDir stringByAppendingString:knownDir]; - if ([[NSFileManager defaultManager] fileExistsAtPath:dataDir]) { - success = true; - break; - } - } - - if (!success) { - return [self showErrorText:@"Failed to extract game data using unshield"]; - } - - // Unmount CD1. Unmount CD2 if needed - [self detachDiskImage:cd1]; - if (![cd1 isEqualToString:cd2]) { - [self detachDiskImage:cd2]; - } -} - -- (void)extractionCompleted -{ - // After game data is extracted we should move it to destination place - [self showProgressText:@"Moving items into place"]; - - NSFileManager* fileManager = [NSFileManager defaultManager]; - - [fileManager moveItemAtPath:[dataDir stringByAppendingString:@"/Data"] toPath:[outputDir stringByAppendingString:@"/Data"] error:nil]; - [fileManager moveItemAtPath:[dataDir stringByAppendingString:@"/Maps"] toPath:[outputDir stringByAppendingString:@"/Maps"] error:nil]; - - if ([fileManager fileExistsAtPath:[dataDir stringByAppendingString:@"/MP3"] isDirectory:nil]) { - [fileManager moveItemAtPath:[dataDir stringByAppendingString:@"/MP3"] toPath:[outputDir stringByAppendingString:@"/Mp3"] error:nil]; - } else { - [fileManager moveItemAtPath:[dataDir stringByAppendingString:@"/Mp3"] toPath:[outputDir stringByAppendingString:@"/Mp3"] error:nil]; - } - - // After everythin is complete we create marker file. VCMI will look for this file to exists on startup and - // will run this setup otherwise - system([[NSString stringWithFormat:@"touch \"%@/game_data_prepared\"", outputDir] UTF8String]); - - [self showProgressText:@"Installation complete"]; - [self.installButton setTitle:@"Run VCMI"]; - [self.progressIndicator stopAnimation:self]; - - // Notify user that installation completed - [self showNotification:@"Installation completed"]; - - // Hide all progress related controls - [self.progressIndicator setHidden:YES]; - [self.progressIndicator stopAnimation:self]; - [self.progressLabel setHidden:YES]; - - [self.installButton setEnabled:YES]; - installationCompleted = YES; -} - -- (void)selectFile:(NSArray*)fileTypes withTextField:(NSTextField*)textField -{ - NSOpenPanel* openPanel = [NSOpenPanel openPanel]; - [openPanel setCanChooseFiles:YES]; - [openPanel setAllowedFileTypes:fileTypes]; - [openPanel setAllowsMultipleSelection:NO]; - - if ([openPanel runModal] == NSOKButton) { - NSString* path = [[openPanel URL] path]; - [textField setStringValue:path]; - } -} - -- (IBAction)selectCD1:(id)sender -{ - [self selectFile:@[@"iso", @"exe"] withTextField:self.cd1TextField]; -} - -- (IBAction)selectCD2:(id)sender -{ - [self selectFile:@[@"iso"] withTextField:self.cd2TextField]; -} - -- (IBAction)install:(id)sender -{ - if (installationCompleted) { - // Run vcmi - system([[NSString stringWithFormat:@"open %@/../../..", [[NSBundle mainBundle] bundlePath]] UTF8String]); - [NSApp terminate: nil]; - } else { - // Run installation - [self.cd1Button setEnabled:NO]; - [self.cd2Button setEnabled:NO]; - [self.installButton setEnabled:NO]; - - actions = [NSMutableArray arrayWithObjects: - @"validateAction", - @"downloadWogArchive", - @"unzipWogArchive", - @"downloadVcmiArchive", - @"unzipVcmiArchive", - @"extractGameData", - @"extractionCompleted", - nil - ]; - - [self nextAction]; - } -} - -- (void)showNotification:(NSString*)text -{ - // Notification Center is supported only on OS X 10.8 and newer - NSUserNotification* notification = [[NSUserNotification alloc] init]; - if (notification != nil) { - notification.title = @"VCMI"; - notification.informativeText = text; - notification.deliveryDate = [NSDate dateWithTimeInterval:0 sinceDate:[NSDate date]]; - notification.soundName = NSUserNotificationDefaultSoundName; - - [[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification:notification]; - } else { - // On older OS X version force dock icon to jump - [NSApp requestUserAttention:NSCriticalRequest]; - } -} - -- (void)showProgressText:(NSString*)text -{ - // All GUI updates should be done on main thread - dispatch_async(dispatch_get_main_queue(), ^{ - [self.progressLabel setHidden:NO]; - [self.progressLabel setStringValue:text]; - }); -} - -- (void)showErrorText:(NSString*)text -{ - // All GUI updates should be done on main thread - dispatch_async(dispatch_get_main_queue(), ^{ - [self showNotification:@"Installation failed"]; - - // Show error alert - NSAlert *alert = [[NSAlert alloc] init]; - [alert setMessageText:@"Error"]; - [alert setInformativeText:text]; - [alert beginSheetModalForWindow:self.window modalDelegate:nil didEndSelector:nil contextInfo:nil]; - - // Enable select file buttons again - [self.cd1Button setEnabled:YES]; - [self.cd2Button setEnabled:YES]; - [self.installButton setEnabled:YES]; - - // Hide all progress related controls - [self.progressIndicator setHidden:YES]; - [self.progressIndicator stopAnimation:self]; - - [self.progressLabel setHidden:YES]; - }); -} - -@end diff --git a/osx/osx-vcmibuilder/vcmibuilder/en.lproj/InfoPlist.strings b/osx/osx-vcmibuilder/vcmibuilder/en.lproj/InfoPlist.strings deleted file mode 100644 index 477b28ff8..000000000 --- a/osx/osx-vcmibuilder/vcmibuilder/en.lproj/InfoPlist.strings +++ /dev/null @@ -1,2 +0,0 @@ -/* Localized versions of Info.plist keys */ - diff --git a/osx/osx-vcmibuilder/vcmibuilder/en.lproj/MainMenu.xib b/osx/osx-vcmibuilder/vcmibuilder/en.lproj/MainMenu.xib deleted file mode 100644 index da95fd9ce..000000000 --- a/osx/osx-vcmibuilder/vcmibuilder/en.lproj/MainMenu.xib +++ /dev/null @@ -1,772 +0,0 @@ - - - - 1070 - 11G63 - 2844 - 1138.51 - 569.00 - - com.apple.InterfaceBuilder.CocoaPlugin - 2844 - - - NSButton - NSButtonCell - NSCustomObject - NSMenu - NSMenuItem - NSProgressIndicator - NSTextField - NSTextFieldCell - NSView - NSWindowTemplate - - - com.apple.InterfaceBuilder.CocoaPlugin - - - PluginDependencyRecalculationVersion - - - - - NSApplication - - - FirstResponder - - - NSApplication - - - AMainMenu - - - - vcmibuilder - - 1048576 - 2147483647 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - - submenuAction: - - vcmibuilder - - - - About vcmibuilder - - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Quit vcmibuilder - q - 1048576 - 2147483647 - - - - - _NSAppleMenu - - - - _NSMainMenu - - - 7 - 2 - {{335, 390}, {572, 194}} - 1954021376 - VCMI Install - NSWindow - - - {572, 207} - - - 256 - - - - 12 - {{20, 83}, {483, 22}} - - - - _NS:9 - YES - - -2074083263 - 272631872 - - - LucidaGrande - 13 - 1044 - - CD1 ISO disk image or installer executable - _NS:9 - - YES - - 6 - System - textBackgroundColor - - 3 - MQA - - - - 6 - System - textColor - - 3 - MAA - - - - - - - 12 - {{20, 51}, {483, 22}} - - - - _NS:9 - YES - - -2074083263 - 272631872 - - - CD2 ISO disk image (optional) - _NS:9 - - YES - - - - - - - 268 - {{17, 140}, {538, 34}} - - - - _NS:1535 - YES - - 68157504 - 272630784 - In order to complete VCMI installation you need original Heroes III: Shadow of Death
game data. Please select ISO disk image or installer executable and press Install. - - _NS:1535 - - - 6 - System - controlColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 6 - System - controlTextColor - - - - - - - 268 - {{505, 76}, {53, 32}} - - - - _NS:9 - YES - - 67108864 - 134217728 - ... - - _NS:9 - - -2038284288 - 129 - - - 200 - 25 - - - - - 268 - {{505, 44}, {53, 32}} - - - - _NS:9 - YES - - 67108864 - 134217728 - ... - - _NS:9 - - -2038284288 - 129 - - - 200 - 25 - - - - - 268 - {{461, 12}, {97, 32}} - - - - _NS:9 - YES - - 67108864 - 134217728 - Install - - _NS:9 - - -2038284288 - 129 - - - 200 - 25 - - - - - -2147483380 - {{20, 22}, {16, 16}} - - - - _NS:945 - 20746 - 100 - - - - -2147483380 - {{41, 22}, {419, 17}} - - - - _NS:1535 - YES - - 67108928 - 272631808 - Label - - _NS:1535 - - - - - - - {572, 194} - - - - - {{0, 0}, {1680, 1028}} - {572, 229} - {10000000000000, 10000000000000} - YES - - - AppDelegate - - - NSFontManager - - - - - - - terminate: - - - - 449 - - - - orderFrontStandardAboutPanel: - - - - 142 - - - - delegate - - - - 495 - - - - window - - - - 532 - - - - cd1Button - - - - 615 - - - - cd2Button - - - - 616 - - - - cd1TextField - - - - 617 - - - - cd2TextField - - - - 618 - - - - selectCD1: - - - - 619 - - - - selectCD2: - - - - 620 - - - - progressLabel - - - - 622 - - - - progressIndicator - - - - 623 - - - - installButton - - - - 624 - - - - install: - - - - 625 - - - - - - 0 - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 29 - - - - - - - - 56 - - - - - - - - 57 - - - - - - - - - - 58 - - - - - 136 - - - - - 149 - - - - - 371 - - - - - - - - 372 - - - - - - - - - - - - - - - 420 - - - - - 494 - - - - - 536 - - - - - - - - 537 - - - - - 541 - - - - - - - - 542 - - - - - 549 - - - - - - - - 550 - - - - - 562 - - - - - - - - 563 - - - - - 569 - - - - - - - - 570 - - - - - 581 - - - - - - - - 582 - - - - - 587 - - - - - 593 - - - - - - - - 594 - - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - com.apple.InterfaceBuilder.CocoaPlugin - {{380, 496}, {480, 360}} - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - - - - 730 - - - - - AppDelegate - NSObject - - id - id - id - - - - install: - id - - - selectCD1: - id - - - selectCD2: - id - - - - NSButton - NSTextField - NSButton - NSTextField - NSTextField - NSButton - NSProgressIndicator - NSTextField - NSWindow - - - - cd1Button - NSButton - - - cd1TextField - NSTextField - - - cd2Button - NSButton - - - cd2TextField - NSTextField - - - errorLabel - NSTextField - - - installButton - NSButton - - - progressIndicator - NSProgressIndicator - - - progressLabel - NSTextField - - - window - NSWindow - - - - IBProjectSource - ./Classes/AppDelegate.h - - - - - 0 - IBCocoaFramework - YES - 3 - - {11, 11} - {10, 3} - - - diff --git a/osx/osx-vcmibuilder/vcmibuilder/main.m b/osx/osx-vcmibuilder/vcmibuilder/main.m deleted file mode 100644 index 04d99dab9..000000000 --- a/osx/osx-vcmibuilder/vcmibuilder/main.m +++ /dev/null @@ -1,6 +0,0 @@ -#import - -int main(int argc, char *argv[]) -{ - return NSApplicationMain(argc, (const char **)argv); -} diff --git a/osx/osx-vcmibuilder/vcmibuilder/vcmibuilder-Info.plist b/osx/osx-vcmibuilder/vcmibuilder/vcmibuilder-Info.plist deleted file mode 100644 index 0d2eff163..000000000 --- a/osx/osx-vcmibuilder/vcmibuilder/vcmibuilder-Info.plist +++ /dev/null @@ -1,34 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIconFile - vcmibuilder - CFBundleIdentifier - com.vcmi.${PRODUCT_NAME:rfc1034identifier} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} - NSHumanReadableCopyright - Copyright © 2012 Alexey Petruchik. All rights reserved. - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - - diff --git a/osx/osx-vcmibuilder/vcmibuilder/vcmibuilder-Prefix.pch b/osx/osx-vcmibuilder/vcmibuilder/vcmibuilder-Prefix.pch deleted file mode 100644 index 63c1a5e8b..000000000 --- a/osx/osx-vcmibuilder/vcmibuilder/vcmibuilder-Prefix.pch +++ /dev/null @@ -1,7 +0,0 @@ -// -// Prefix header for all source files of the 'vcmibuilder' target in the 'vcmibuilder' project -// - -#ifdef __OBJC__ - #import -#endif diff --git a/osx/package.sh b/osx/package.sh deleted file mode 100644 index a3d0547dd..000000000 --- a/osx/package.sh +++ /dev/null @@ -1,15 +0,0 @@ -# Clean previous build -rm -rf build -rm -rf bin -rm -rf osx/osx-vcmibuilder/build -rm -rf osx/vcmibuilder.app - -# Build vcmibuilder -xcodebuild -project osx/osx-vcmibuilder/vcmibuilder.xcodeproj/ -configuration Release -mv osx/osx-vcmibuilder/build/Release/vcmibuilder.app osx/vcmibuilder.app - -# Build vcmi -mkdir build -cd build -cmake -G Xcode .. -DENABLE_LAUNCHER=OFF -xcodebuild -project vcmi.xcodeproj/ -configuration Release -target package \ No newline at end of file diff --git a/osx/sparkle_appcast.xml b/osx/sparkle_appcast.xml deleted file mode 100644 index 8ffd00a7d..000000000 --- a/osx/sparkle_appcast.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - VCMI App Changelog - https://vcmi.eu/sparkle_appcast.xml - Most recent changes with links to updates. - en - - Version 0.94 - Version 0.94 - Wed, 09 Jan 2006 19:20:11 +0000 - http://vcmi.eu/sparkle_release_notes.html - - - - Version 0.93 - Version 0.93 - Wed, 09 Jan 2006 19:20:11 +0000 - http://vcmi.eu/sparkle_release_notes.html - - - - Version 0.92 - Version 0.92 - Wed, 09 Jan 2006 19:20:11 +0000 - http://vcmi.eu/sparkle_release_notes.html - - - - diff --git a/osx/sparkle_release_notes.html b/osx/sparkle_release_notes.html deleted file mode 100644 index 35e989fc4..000000000 --- a/osx/sparkle_release_notes.html +++ /dev/null @@ -1,171 +0,0 @@ - - -

0.94

- GENERAL -
    -
  • Filesystem now supports zip archives. They can be loaded similarly to other archives in filesystem.json. Mods can use Content.zip instead of Content/ directory.
  • -
  • fixed "get txt" console command
  • -
  • command "extract" to extract file by name
  • -
  • command "def2bmp" to convert def into set of frames.
  • -
  • fixed crash related to cammander's SPELL_AFTER_ATTACK spell id not initialized properly (text id was resolved on copy of bonus)
  • -
  • fixed duels, added no-GUI mode for automatic AI testing
  • -
  • Sir Mullich is available at the start of the game
  • -
  • Upgrade cost will never be negative.
  • -
  • support for Chinese fonts (GBK 2-byte encoding)
  • -
- ADVENTURE MAP -
    -
  • if Quick Combat option is turned on, battles will be resolved by AI
  • -
  • first hero is awakened on new turn
  • -
  • fixed 3000 gems reward in shipwreck
  • -
- BATTLES -
    -
  • autofight implemented
  • -
  • most of the animations is time-based
  • -
  • simplified postioning of units in battle, should fix remaining issues with unit positioning
  • -
  • synchronized attack/defence animation
  • -
  • spell animation speed uses game settings
  • -
  • fixed disrupting ray duration
  • -
  • added logging domain for battle animations
  • -
  • Fixed crashes on Land Mines / Fire Wall casting.
  • -
  • UI will be correctly greyed-out during opponent turn
  • -
  • fixed remaining issues with blit order
  • -
  • Catapult attacks should be identical to H3. Catapult may miss and attack another part of wall instead (this is how it works in H3)
  • -
  • Fixed Remove Obstacle.
  • -
  • defeating hero will yield 500 XP
  • -
  • Added lots of missing spell immunities from Strategija
  • -
  • Added stone gaze immunity for Troglodytes (did you know about it?)
  • -
  • damage done by turrets is properly increased by built buldings
  • -
  • Wyverns will cast Poison instead of Stone Gaze.
  • -
- TOWN -
    -
  • Fixed issue that allowed to build multiple boats in town.
  • -
  • fix for lookout tower
  • -
-
- -

0.93

- GENERAL -
    -
  • Support for SoD-only installations, WoG becomes optional addition
  • -
  • New logging framework
  • -
  • Negative luck support, disabled by default
  • -
  • Several new icons for creature abilities (Fire Shield, Non-living, Magic Mirror, Spell-like Attack)
  • -
  • Fixed stack artifact (and related buttons) not displaying in creature window.
  • -
  • Fixed crash at month of double population.
  • -
- MODS -
    -
  • See http://wiki.vcmi.eu/index.php?title=Modding_changelog#0.92_-.3E_0.93 for compatibility info.
  • -
  • Improved json validation. Now it support most of features from latest json schema draft.
  • -
  • Icons use path to icon instead of image indexes.
  • -
  • It is possible to edit data of another mod or H3 data via mods.
  • -
  • Mods can access only ID's from dependenies, virtual "core" mod and itself (optional for some mods compatibility)
  • -
  • Removed no longer needed field "projectile spins"
  • -
  • Heroes: split heroes.json in manner similar to creatures\factions; string ID's for H3 heroes; h3 hero classes and artifacts can be modified via json.
  • -
- BATTLES -
    -
  • Fixed Death Stare of Commanders
  • -
  • Projectile blitting should be closer to original H3. But still not perfect.
  • -
  • Fixed missing Mirth effects
  • -
  • Stack affected by Berserk should not try to attack itself
  • -
  • Fixed several cases of incorrect positioning of creatures in battles
  • -
  • Fixed abilities of Efreet.
  • -
  • Fixed broken again palette in some battle backgrounds
  • -
- TOWN -
    -
  • VCMI will not crash if building selection area is smaller than def
  • -
  • Detection of transparency on selection area is closer to H3
  • -
  • Improved handling buildings with mode "auto": -
      -
    • they will be properly processed (new creatures will be added if dwelling, spells learned if mage guild, and so on)
    • -
    • transitive dependencies are handled (A makes B build, and B makes C and D)
    • -
    -
  • -
- SOUND -
    -
  • Added missing WoG creature sounds (from Kuririn).
  • -
  • The Windows package comes with DLLs needed to play .ogg files
  • -
  • (linux) convertMP3 option for vcmibuilder for systems where SDL_Mixer can't play mp3's
  • -
  • some missing sounds for battle effects
  • -
- ARTIFACTS -
    -
  • Several fixes to combined artifacts added via mods.
  • -
  • Fixed Spellbinder's Hat giving level 1 spells instead of 5.
  • -
  • Fixed incorrect components of Cornucopia.
  • -
  • Cheat code with grant all artifacts, including the ones added by mods
  • -
-
- -

0.92

- GENERAL -
    -
  • hero crossover between missions in campaigns
  • -
  • introduction before missions in campaigns
  • -
- MODS -
    -
  • Added CREATURE_SPELL_POWER for commanders
  • -
  • Added spell modifiers to various spells: Hypnotize (Astral), Firewall (Luna), Landmine
  • -
  • Fixed ENEMY_DEFENCE_REDUCTION, GENERAL_ATTACK_REDUCTION
  • -
  • Extended usefulness of ONLY_DISTANCE_FIGHT, ONLY_MELEE_FIGHT ranges
  • -
  • Double growth creatures are configurable now
  • -
  • Drain Life now has % effect depending on bonus value
  • -
  • Stack can use more than 2 attacks. Additional attacks can now be separated as "ONLY_MELEE_FIGHT and "ONLY_DISTANCE_FIGHT".
  • -
  • Moat damage configurable
  • -
  • More config options for spells: -
      -
    • mind immunity handled by config
    • -
    • direct damage immunity handled by config
    • -
    • immunity icon configurable
    • -
    • removed mind_spell flag
    • -
    -
  • -
  • creature config use string ids now.
  • -
  • support for string subtype id in short bonus format
  • -
  • primary skill identifiers for bonuses
  • -
-

0.91

- GENERAL -
    -
  • VCMI build on OS X is now supported
  • -
  • Completely removed autotools
  • -
  • Added RMG interace and ability to generate simplest working maps
  • -
  • Added loading screen
  • -
- MODS -
    -
  • Simplified mod structure. Mods from 0.9 will not be compatible.
  • -
      -
    • Mods can be turned on and off in config/modSettings.json file
    • -
    • Support for new factions, including:
    • -
    -
  • New towns
  • -
  • New hero classes
  • -
  • New heroes
  • -
  • New town-related external dwellings
  • -
      -
    • Support for new artifact, including combined, commander and stack artifacts
    • -
    • Extended configuration options
    • -
    -
  • All game objects are referenced by string identifiers
  • -
  • Subtype resolution for bonuses
  • -
- BATTLES -
    -
  • Support for "enchanted" WoG ability
  • -
- ADVENTURE AI -
    -
  • AI will try to use Subterranean Gate, Redwood Observatory and Cartographer for exploration
  • -
  • Improved exploration algorithm
  • -
  • AI will prioritize dwellings and mines when there are no opponents visible
  • -
- - \ No newline at end of file diff --git a/client/vcmi.icns b/osx/vcmi.icns similarity index 100% rename from client/vcmi.icns rename to osx/vcmi.icns diff --git a/osx/vcmi_dsa_public.pem b/osx/vcmi_dsa_public.pem deleted file mode 100644 index c1092aff0..000000000 --- a/osx/vcmi_dsa_public.pem +++ /dev/null @@ -1,12 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIBuDCCASwGByqGSM44BAEwggEfAoGBAPBRGeziJsHw0F7CM9JmSOiIOBmJ4hYl -dbmdU1iJR7XHX5lZIUOl323cCANhzOogVAzkvEVhFedA6H4iO6VRt7nTJSgLA4hO -gMqMJGKp4bDQIwupUK5xQUUcaXumT03Aj8jzzibW9YjNB8NeuSSMfMi5KGZw5pkf -nSvZM0TUVVX/AhUA74nJWqRFwUPc6aPGCOgfsRzPYMsCgYEApYMP5/tIr4yrqHVM -xHLj1s+Y/Zgs3+kRqudTLgYE20Br3Tmmi2ejM9phrEHn5mv6Ss/FYyWqKxdtzCEN -PjRA/JkKMpoX+sy/S3OE/NrrnikVjCRvgOJcM6FPt9iaENRqjz20dZMIq42vqeE9 -K5u1XJ/YtiwU2b1fX0nNtREhjUwDgYUAAoGBAJT2cMQ2qTGecdNIjEByCFMZpWg0 -nV+jKgpthNUahwxbUN3ru9nrWMUNv1pBiS3pxqFV6ec7qozKnedwyTx+IRJXTN4T -IrxYsgPJDHhkBeoVVAkacihkLUtwPSphorZWF4OMFmrlc5WsmYt2lEahR2TZGQrW -5GBNP18/S/nDBe7j ------END PUBLIC KEY----- diff --git a/scripting/erm/CMakeLists.txt b/scripting/erm/CMakeLists.txt index f121fe45e..f0fb40748 100644 --- a/scripting/erm/CMakeLists.txt +++ b/scripting/erm/CMakeLists.txt @@ -1,6 +1,3 @@ -project(vcmiERM) -cmake_minimum_required(VERSION 2.6) - include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIRECTORY}) set(lib_SRCS diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 18a6d63af..e2ace12ad 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -1,6 +1,3 @@ -project(vcmiserver) -cmake_minimum_required(VERSION 2.6) - include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib) include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) @@ -20,6 +17,9 @@ set(server_HEADERS CQuery.h CVCMIServer.h ) + +assign_source_group(${server_SRCS} ${server_HEADERS}) + if(ANDROID) # android needs client/server to be libraries, not executables, so we can't reuse the build part of this script return() endif() @@ -29,15 +29,16 @@ add_executable(vcmiserver ${server_SRCS} ${server_HEADERS}) target_link_libraries(vcmiserver vcmi ${Boost_LIBRARIES} ${SYSTEM_LIBS}) if(WIN32) - set_target_properties(vcmiserver PROPERTIES OUTPUT_NAME VCMI_server) + set_target_properties(vcmiserver + PROPERTIES + OUTPUT_NAME "VCMI_server" + PROJECT_LABEL "VCMI_server" + ) endif() vcmi_set_output_dir(vcmiserver "") set_target_properties(vcmiserver PROPERTIES ${PCH_PROPERTIES}) -set_target_properties(vcmiserver PROPERTIES XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks @executable_path/") 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/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index 0fca27ed0..5515de66e 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -609,7 +609,7 @@ void handleLinuxSignal(int sig) int main(int argc, char * argv[]) { -#ifdef VCMI_APPLE +#ifndef VCMI_WINDOWS // Correct working dir executable folder (not bundle folder) so we can use executable relative paths std::string executablePath = argv[0]; std::string workDir = executablePath.substr(0, executablePath.rfind('/')); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a68b03c14..c904a93f8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,16 +1,12 @@ -cmake_minimum_required(VERSION 2.8.7) - -project(test) - enable_testing() set(googleTest_Dir ${CMAKE_CURRENT_SOURCE_DIR}/googletest) -if (EXISTS ${googleTest_Dir}) - SET(GTestSrc ${googleTest_Dir}/googletest) - SET(GMockSrc ${googleTest_Dir}/googlemock) -else () - message( FATAL_ERROR "No googletest src dir found!") -endif () +if(EXISTS ${googleTest_Dir}) + set(GTestSrc ${googleTest_Dir}/googletest) + set(GMockSrc ${googleTest_Dir}/googlemock) +else() + message(FATAL_ERROR "No googletest src dir found!") +endif() include_directories(${GTestSrc} ${GTestSrc}/include ${GMockSrc} ${GMockSrc}/include) include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/test) include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) @@ -36,10 +32,13 @@ set(test_HEADERS map/MapComparer.h ) +assign_source_group(${test_SRCS} ${test_HEADERS}) + set(mock_HEADERS mock/mock_UnitHealthInfo.h ) -add_subdirectory(googletest) + +add_subdirectory_with_folder("3rdparty" googletest EXCLUDE_FROM_ALL) add_executable(vcmitest ${test_SRCS} ${test_HEADERS} ${mock_HEADERS} ${GTestSrc}/src/gtest-all.cc ${GMockSrc}/src/gmock-all.cc) target_link_libraries(vcmitest vcmi ${RT_LIB} ${DL_LIB}) @@ -51,7 +50,6 @@ set_target_properties(vcmitest PROPERTIES ${PCH_PROPERTIES}) cotire(vcmitest) # Files to copy to the build directory -add_custom_target(vcmitestFiles ALL) set(vcmitest_FILES testdata/TerrainViewTest.h3m testdata/terrainViewMappings.json @@ -62,7 +60,7 @@ set(vcmitest_FILES ) foreach(file ${vcmitest_FILES}) - add_custom_command(TARGET vcmitestFiles POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${file}" ${CMAKE_CURRENT_BINARY_DIR} + add_custom_command(TARGET vcmitest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${file}" ${CMAKE_CURRENT_BINARY_DIR} ) endforeach()