diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 188 |
1 files changed, 98 insertions, 90 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a33e4736..0986b900 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,14 +27,14 @@ ENDIF() ######## Set compiler flags ######## IF(APPLE) message(STATUS "Using APPLE CMAKE_CXX_FLAGS") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") ELSEIF(UNIX) # assume GCC, add C++0x/C++11 stuff MESSAGE(STATUS "Using UNIX CMAKE_CXX_FLAGS") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") ELSEIF(MINGW) MESSAGE(STATUS "Using MINGW CMAKE_CXX_FLAGS") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall") ENDIF() ################################ INCLUDE LIBRARIES ################################ @@ -48,6 +48,23 @@ find_package(Qt5LinguistTools REQUIRED) include_directories(${Qt5Widgets_INCLUDE_DIRS}) +# The Qt5 cmake files don't provide its install paths, so ask qmake. +get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION) +function(QUERY_QMAKE VAR RESULT) + exec_program(${QMAKE_EXECUTABLE} ARGS "-query ${VAR}" RETURN_VALUE return_code OUTPUT_VARIABLE output ) + if(NOT return_code) + file(TO_CMAKE_PATH "${output}" output) + set(${RESULT} ${output} PARENT_SCOPE) + endif(NOT return_code) +endfunction(QUERY_QMAKE) + +query_qmake(QT_INSTALL_PLUGINS QT_PLUGINS_DIR) +query_qmake(QT_INSTALL_IMPORTS QT_IMPORTS_DIR) +query_qmake(QT_INSTALL_LIBS QT_LIBS_DIR) +query_qmake(QT_HOST_DATA QT_DATA_DIR) +set(QT_MKSPECS_DIR ${QT_DATA_DIR}/mkspecs) + + ######## Included Libs ######## # Add quazip @@ -429,7 +446,6 @@ CONFIGURE_FILE(generated.qrc.in generated.qrc) QT5_ADD_RESOURCES(GENERATED_QRC ${CMAKE_CURRENT_BINARY_DIR}/generated.qrc) QT5_ADD_RESOURCES(GRAPHICS_QRC graphics.qrc) - # Add executable ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32 ${MULTIMC_SOURCES} ${MULTIMC_UI} ${GRAPHICS_QRC} ${GENERATED_QRC} ${MULTIMC_RCS}) @@ -439,110 +455,102 @@ TARGET_LINK_LIBRARIES(MultiMC xz-embedded unpack200 quazip libUtil libSettings l QT5_USE_MODULES(MultiMC Core Widgets Network Xml ${MultiMC_QT_ADDITIONAL_MODULES}) ADD_DEPENDENCIES(MultiMC MultiMCLauncher JavaCheck) -option(BUILD_KEYRING_TEST "Build the simple keyring test binary" OFF) -IF(BUILD_KEYRING_TEST) - # test.cpp - ADD_EXECUTABLE(Test test.cpp) - QT5_USE_MODULES(Test Core) - TARGET_LINK_LIBRARIES(Test libUtil libSettings) -ENDIF() - ################################ INSTALLATION AND PACKAGING ################################ -# use QtCreator's QTDIR var -IF(DEFINED ENV{QTDIR}) - SET(Qt5_DIR $ENV{QTDIR}) -ENDIF() -######## Plugin and library folders ######## - -SET(PLUGIN_DEST_DIR plugins) -SET(QTCONF_DEST_DIR .) -SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC") - -IF(WIN32) - SET(PLUGIN_DEST_DIR .) - SET(QTCONF_DEST_DIR .) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe") -ENDIF() +######## Packaging/install paths setup ######## -IF(UNIX) -IF(APPLE) +IF(UNIX AND APPLE) SET(PLUGIN_DEST_DIR MultiMC.app/Contents/MacOS) SET(QTCONF_DEST_DIR MultiMC.app/Contents/Resources) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.app") -ELSE() - SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC") -ENDIF() -ENDIF() - -SET(QT_PLUGINS_DIR ${Qt5_DIR}/plugins) -SET(QT_LIBRARY_DIRS ${Qt5_DIR}/lib) + SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.app") - -######## OS X Bundle Info ######## - -IF(APPLE) SET(MACOSX_BUNDLE_BUNDLE_NAME "MultiMC") SET(MACOSX_BUNDLE_INFO_STRING "MultiMC Minecraft launcher and management utility.") - SET(MACOSX_BUNDLE_BUNDLE_VERSION - "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_REV}.${MultiMC_VERSION_BUILD}") + SET(MACOSX_BUNDLE_BUNDLE_VERSION "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_REV}.${MultiMC_VERSION_BUILD}") #SET(MACOSX_BUNDLE_GUI_IDENTIFIER "") SET(MACOSX_BUNDLE_ICON_FILE MultiMC.icns) -ENDIF(APPLE) +ELSEIF(UNIX) + SET(PLUGIN_DEST_DIR plugins) + SET(QTCONF_DEST_DIR .) + SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC") +ELSEIF(WIN32) + SET(PLUGIN_DEST_DIR .) + SET(QTCONF_DEST_DIR .) + SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe") +ENDIF() + +# directories to look for dependencies +SET(DIRS "${QT_LIBS_DIR}") ######## Install ######## #### Executable #### -IF(WIN32) -INSTALL(TARGETS MultiMC - BUNDLE DESTINATION . COMPONENT Runtime - LIBRARY DESTINATION . COMPONENT Runtime - RUNTIME DESTINATION . COMPONENT Runtime -) -ENDIF() -IF(UNIX) -IF(APPLE) -INSTALL(TARGETS MultiMC - BUNDLE DESTINATION . COMPONENT Runtime - RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime -) -ELSE() -INSTALL(TARGETS MultiMC - BUNDLE DESTINATION . COMPONENT Runtime - RUNTIME DESTINATION bin COMPONENT Runtime -) -INSTALL(PROGRAMS package/linux/MultiMC DESTINATION .) -ENDIF() -ENDIF() +IF(APPLE AND UNIX) ## OSX + INSTALL(TARGETS MultiMC + BUNDLE DESTINATION . COMPONENT Runtime + RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime + ) +ELSEIF(UNIX) ## LINUX and similar + INSTALL(TARGETS MultiMC + BUNDLE DESTINATION . COMPONENT Runtime + RUNTIME DESTINATION bin COMPONENT Runtime + ) + INSTALL(PROGRAMS package/linux/MultiMC DESTINATION .) -#### Plugins #### +ELSEIF(WIN32) ## WINDOWS + INSTALL(TARGETS MultiMC + BUNDLE DESTINATION . COMPONENT Runtime + LIBRARY DESTINATION . COMPONENT Runtime + RUNTIME DESTINATION . COMPONENT Runtime + ) +ENDIF() -OPTION(MultiMC_INSTALL_SHARED_LIBS "if set, Qt's shared libraries will be copied to the installation directory on install") +#### Dist package logic #### -IF (MultiMC_INSTALL_SHARED_LIBS) - # Image formats - INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime) +# Image formats +INSTALL( + DIRECTORY "${QT_PLUGINS_DIR}/imageformats" + DESTINATION ${PLUGIN_DEST_DIR} + COMPONENT Runtime + REGEX "tga|svg|tiff|mng" EXCLUDE + REGEX "d\\." EXCLUDE +) - # Platform plugins - INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/platforms" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime) +# Platform plugins +INSTALL( + DIRECTORY "${QT_PLUGINS_DIR}/platforms" + DESTINATION ${PLUGIN_DEST_DIR} + COMPONENT Runtime + REGEX "minimal|linuxfb|offscreen" EXCLUDE + REGEX "d\\." EXCLUDE +) - # qtconf - INSTALL(CODE " - FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/${QTCONF_DEST_DIR}/qt.conf\" \"\") - " COMPONENT Runtime) +# qtconf +INSTALL( + CODE " +FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/${QTCONF_DEST_DIR}/qt.conf\" \"\") +" + COMPONENT Runtime +) - # Dirs to look for dependencies. - SET(DIRS "${QT_LIBRARY_DIRS}") +INSTALL( + CODE " +FILE(GLOB_RECURSE QTPLUGINS \"\${CMAKE_INSTALL_PREFIX}/${PLUGIN_DEST_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\") +function(gp_resolved_file_type_override resolved_file type_var) + if(resolved_file MATCHES \"^/usr/lib/libQt\") + message(\"resolving \${resolved_file} as system\") + set(\${type_var} other PARENT_SCOPE) + endif() +endfunction() + +include(BundleUtilities) +fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\") +" + COMPONENT Runtime +) - INSTALL(CODE " - file(GLOB_RECURSE QTPLUGINS - \"\${CMAKE_INSTALL_PREFIX}/${PLUGIN_DEST_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\") - include(BundleUtilities) - fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\") - " COMPONENT Runtime) -ENDIF() ######## Package ######## @@ -586,11 +594,11 @@ include_directories(${PROJECT_BINARY_DIR}/include) file (GLOB TRANSLATIONS_FILES translations/*.ts) option (UPDATE_TRANSLATIONS "Update source translation translations/*.ts files (WARNING: make clean will delete the source .ts files! Danger!)") -if (UPDATE_TRANSLATIONS) - qt5_create_translation(QM_FILES ${FILES_TO_TRANSLATE} ${TRANSLATIONS_FILES}) -else (UPDATE_TRANSLATIONS) - qt5_add_translation(QM_FILES ${TRANSLATIONS_FILES}) -endif (UPDATE_TRANSLATIONS) +IF(UPDATE_TRANSLATIONS) + qt5_create_translation(QM_FILES ${FILES_TO_TRANSLATE} ${TRANSLATIONS_FILES}) +ELSE() + qt5_add_translation(QM_FILES ${TRANSLATIONS_FILES}) +ENDIF() add_custom_target (translations DEPENDS ${QM_FILES}) |