Merge remote-tracking branch 'origin/feature_cmake_style' into develop

Conflicts:
	CMakeLists.txt
This commit is contained in:
Petr Mrázek 2014-04-21 23:33:00 +02:00
commit 9d724e0fe4
18 changed files with 753 additions and 814 deletions

File diff suppressed because it is too large Load Diff

View File

@ -17,19 +17,19 @@ find_program(CURL_EXECUTABLE NAMES curl PATHS /usr/bin)
if(NOT CURL_EXECUTABLE STREQUAL "" AND NOT MultiMC_COVERITY_TOKEN STREQUAL "" AND NOT MultiMC_COVERITY_EMAIL STREQUAL "") if(NOT CURL_EXECUTABLE STREQUAL "" AND NOT MultiMC_COVERITY_TOKEN STREQUAL "" AND NOT MultiMC_COVERITY_EMAIL STREQUAL "")
add_custom_target(coverity_configure add_custom_target(coverity_configure
COMMAND ${MultiMC_COVERITY_TOOLS_DIR}/bin/cov-configure --comptype gcc --compiler ${CMAKE_C_COMPILER} COMMAND ${MultiMC_COVERITY_TOOLS_DIR}/bin/cov-configure --comptype gcc --compiler ${CMAKE_C_COMPILER}
) )
add_custom_target(coverity_create_tarball add_custom_target(coverity_create_tarball
COMMAND ${CMAKE_COMMAND} -E echo "Cleaning..." && ${CMAKE_MAKE_PROGRAM} clean COMMAND ${CMAKE_COMMAND} -E echo "Cleaning..." && ${CMAKE_MAKE_PROGRAM} clean
COMMAND ${CMAKE_COMMAND} -E echo "Building..." && ${MultiMC_COVERITY_TOOLS_DIR}/bin/cov-build --dir cov-int ${CMAKE_MAKE_PROGRAM} -j3 COMMAND ${CMAKE_COMMAND} -E echo "Building..." && ${MultiMC_COVERITY_TOOLS_DIR}/bin/cov-build --dir cov-int ${CMAKE_MAKE_PROGRAM} -j3
COMMAND ${CMAKE_COMMAND} -E echo "Creating tarball..." && ${CMAKE_COMMAND} -E tar cfz multimc_coverity.tgz cov-int/ COMMAND ${CMAKE_COMMAND} -E echo "Creating tarball..." && ${CMAKE_COMMAND} -E tar cfz multimc_coverity.tgz cov-int/
COMMENT "Creating coverity build..." COMMENT "Creating coverity build..."
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
) )
add_custom_target(coverity_upload add_custom_target(coverity_upload
COMMAND ${CURL_EXECUTABLE} --form project=02JanDal/MultiMC5 --form token=${MultiMC_COVERITY_TOKEN} --form email=${MultiMC_COVERITY_EMAIL} --form file=@multimc_coverity.tgz --form version=${MultiMC_GIT_COMMIT} --form description=${GIT_VERSION} http://scan5.coverity.com/cgi-bin/upload.py COMMAND ${CURL_EXECUTABLE} --form project=02JanDal/MultiMC5 --form token=${MultiMC_COVERITY_TOKEN} --form email=${MultiMC_COVERITY_EMAIL} --form file=@multimc_coverity.tgz --form version=${MultiMC_GIT_COMMIT} --form description=${GIT_VERSION} http://scan5.coverity.com/cgi-bin/upload.py
DEPENDS coverity_create_tarball DEPENDS coverity_create_tarball
COMMENT "Uploading to coverity..." COMMENT "Uploading to coverity..."
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
) )
endif() endif()

View File

@ -14,10 +14,10 @@ if(GIT_FOUND)
cmake_parse_arguments(GIT_RUN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(GIT_RUN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
execute_process(COMMAND ${GIT_EXECUTABLE} ${GIT_RUN_COMMAND} execute_process(COMMAND ${GIT_EXECUTABLE} ${GIT_RUN_COMMAND}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE GIT_RESULTVAR RESULT_VARIABLE GIT_RESULTVAR
OUTPUT_VARIABLE GIT_OUTVAR OUTPUT_VARIABLE GIT_OUTVAR
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
if(GIT_RESULTVAR EQUAL 0) if(GIT_RESULTVAR EQUAL 0)

View File

@ -1,33 +0,0 @@
cmake_minimum_required(VERSION 2.8.9)
message(STATUS "Running install script...")
SET(Qt5_DIR @Qt5_DIR@)
IF(WIN32)
SET(LIB_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
ELSE()
SET(LIB_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/lib)
ENDIF()
INCLUDE(GetPrerequisites)
GET_PREREQUISITES(@BINARY_LOCATION@ MULTIMC_PREREQS 1 1 "" "")
message(STATUS "Prerequisites: ${MULTIMC_PREREQS}")
FOREACH(PREREQ ${MULTIMC_PREREQS})
GET_FILENAME_COMPONENT(PREREQ_NAME "${PREREQ}" NAME)
GET_FILENAME_COMPONENT(PREREQ_ACTUAL "${PREREQ}" REALPATH)
IF(WIN32)
SET(PREREQ_ACTUAL "${Qt5_DIR}/bin/${PREREQ}")
ENDIF()
message(STATUS "Adding install prerequisite: ${PREREQ_NAME}")
FILE(INSTALL
DESTINATION "${LIB_INSTALL_PREFIX}"
TYPE PROGRAM
RENAME "${PREREQ_NAME}"
FILES "${PREREQ_ACTUAL}"
)
ENDFOREACH()

View File

@ -8,7 +8,7 @@ find_package(Qt5Core REQUIRED)
# Include Qt headers. # Include Qt headers.
include_directories(${Qt5Base_INCLUDE_DIRS}) include_directories(${Qt5Base_INCLUDE_DIRS})
SET(CLASSPARSER_HEADERS set(CLASSPARSER_HEADERS
include/classparser_config.h include/classparser_config.h
# Public headers # Public headers
@ -23,13 +23,13 @@ src/javaendian.h
src/membuffer.h src/membuffer.h
) )
SET(CLASSPARSER_SOURCES set(CLASSPARSER_SOURCES
src/javautils.cpp src/javautils.cpp
src/annotations.cpp src/annotations.cpp
) )
# Set the include dir path. # Set the include dir path.
SET(LIBGROUPVIEW_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE) set(LIBGROUPVIEW_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
# Include self. # Include self.
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

View File

@ -7,9 +7,9 @@ set(CMAKE_JAVA_JAR_ENTRY_POINT JavaCheck)
set(CMAKE_JAVA_COMPILE_FLAGS -target 1.6 -source 1.6 -Xlint:deprecation -Xlint:unchecked) set(CMAKE_JAVA_COMPILE_FLAGS -target 1.6 -source 1.6 -Xlint:deprecation -Xlint:unchecked)
set(SRC set(SRC
JavaCheck.java JavaCheck.java
) )
add_jar(JavaCheck ${SRC}) add_jar(JavaCheck ${SRC})
INSTALL_JAR(JavaCheck "${BINARY_DEST_DIR}/jars") install_jar(JavaCheck "${BINARY_DEST_DIR}/jars")

View File

@ -8,28 +8,28 @@ set(CMAKE_JAVA_COMPILE_FLAGS -target 1.6 -source 1.6 -Xlint:deprecation -Xlint:u
set(SRC set(SRC
# OSX things # OSX things
org/simplericity/macify/eawt/Application.java org/simplericity/macify/eawt/Application.java
org/simplericity/macify/eawt/ApplicationAdapter.java org/simplericity/macify/eawt/ApplicationAdapter.java
org/simplericity/macify/eawt/ApplicationEvent.java org/simplericity/macify/eawt/ApplicationEvent.java
org/simplericity/macify/eawt/ApplicationListener.java org/simplericity/macify/eawt/ApplicationListener.java
org/simplericity/macify/eawt/DefaultApplication.java org/simplericity/macify/eawt/DefaultApplication.java
# legacy applet wrapper thing. # legacy applet wrapper thing.
# The launcher has to be there for silly FML/Forge relauncher. # The launcher has to be there for silly FML/Forge relauncher.
net/minecraft/Launcher.java net/minecraft/Launcher.java
org/multimc/legacy/LegacyLauncher.java org/multimc/legacy/LegacyLauncher.java
org/multimc/legacy/LegacyFrame.java org/multimc/legacy/LegacyFrame.java
# onesix launcher # onesix launcher
org/multimc/onesix/OneSixLauncher.java org/multimc/onesix/OneSixLauncher.java
# generic launcher # generic launcher
org/multimc/EntryPoint.java org/multimc/EntryPoint.java
org/multimc/Launcher.java org/multimc/Launcher.java
org/multimc/ParseException.java org/multimc/ParseException.java
org/multimc/Utils.java org/multimc/Utils.java
org/multimc/IconLoader.java org/multimc/IconLoader.java
) )
add_jar(NewLaunch ${SRC}) add_jar(NewLaunch ${SRC})
INSTALL_JAR(NewLaunch "${BINARY_DEST_DIR}/jars") install_jar(NewLaunch "${BINARY_DEST_DIR}/jars")

View File

@ -1,59 +1,59 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
IF(WIN32) if(WIN32)
# In Qt 5.1+ we have our own main() function, don't autolink to qtmain on Windows # In Qt 5.1+ we have our own main() function, don't autolink to qtmain on Windows
cmake_policy(SET CMP0020 OLD) cmake_policy(SET CMP0020 OLD)
ENDIF() endif()
project(unpack200) project(unpack200)
# Find ZLIB for quazip # Find ZLIB for quazip
# Use system zlib on unix and Qt ZLIB on Windows # Use system zlib on unix and Qt ZLIB on Windows
IF(UNIX) if(UNIX)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
ELSE(UNIX) else(UNIX)
get_filename_component (ZLIB_FOUND_DIR "${Qt5Core_DIR}/../../../include/QtZlib" ABSOLUTE) get_filename_component(ZLIB_FOUND_DIR "${Qt5Core_DIR}/../../../include/QtZlib" ABSOLUTE)
SET(ZLIB_INCLUDE_DIRS ${ZLIB_FOUND_DIR} CACHE PATH "Path to ZLIB headers of Qt") set(ZLIB_INCLUDE_DIRS ${ZLIB_FOUND_DIR} CACHE PATH "Path to ZLIB headers of Qt")
SET(ZLIB_LIBRARIES "") set(ZLIB_LIBRARIES "")
IF(NOT EXISTS "${ZLIB_INCLUDE_DIRS}/zlib.h") if(NOT EXISTS "${ZLIB_INCLUDE_DIRS}/zlib.h")
MESSAGE("Please specify a valid zlib include dir") message("Please specify a valid zlib include dir")
ENDIF(NOT EXISTS "${ZLIB_INCLUDE_DIRS}/zlib.h") endif(NOT EXISTS "${ZLIB_INCLUDE_DIRS}/zlib.h")
ENDIF(UNIX) endif(UNIX)
SET(PACK200_SRC set(PACK200_SRC
include/unpack200.h include/unpack200.h
src/bands.cpp src/bands.cpp
src/bands.h src/bands.h
src/bytes.cpp src/bytes.cpp
src/bytes.h src/bytes.h
src/coding.cpp src/coding.cpp
src/coding.h src/coding.h
src/constants.h src/constants.h
src/defines.h src/defines.h
src/unpack200.cpp src/unpack200.cpp
src/unpack.cpp src/unpack.cpp
src/unpack.h src/unpack.h
src/utils.cpp src/utils.cpp
src/utils.h src/utils.h
src/zip.cpp src/zip.cpp
src/zip.h src/zip.h
) )
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET(PACK200_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE) set(PACK200_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
include_directories( include_directories(
include include
${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}
) )
add_library(unpack200 STATIC ${PACK200_SRC}) add_library(unpack200 STATIC ${PACK200_SRC})
IF(UNIX) if(UNIX)
target_link_libraries(unpack200 ${ZLIB_LIBRARIES}) target_link_libraries(unpack200 ${ZLIB_LIBRARIES})
ELSE() else()
# zlib is part of Qt on windows. use it. # zlib is part of Qt on windows. use it.
QT5_USE_MODULES(unpack200 Core) qt5_use_modules(unpack200 Core)
ENDIF() endif()
add_executable(anti200 anti200.cpp) add_executable(anti200 anti200.cpp)
target_link_libraries(anti200 unpack200) target_link_libraries(anti200 unpack200)

View File

@ -2,16 +2,16 @@ project(quazip)
# Find ZLIB for quazip # Find ZLIB for quazip
# Use system zlib on unix and Qt ZLIB on Windows # Use system zlib on unix and Qt ZLIB on Windows
IF(UNIX) if(UNIX)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
ELSE(UNIX) else(UNIX)
get_filename_component (ZLIB_FOUND_DIR "${Qt5Core_DIR}/../../../include/QtZlib" ABSOLUTE) get_filename_component(ZLIB_FOUND_DIR "${Qt5Core_DIR}/../../../include/QtZlib" ABSOLUTE)
SET(ZLIB_INCLUDE_DIRS ${ZLIB_FOUND_DIR} CACHE PATH "Path to ZLIB headers of Qt") set(ZLIB_INCLUDE_DIRS ${ZLIB_FOUND_DIR} CACHE PATH "Path to ZLIB headers of Qt")
SET(ZLIB_LIBRARIES "") set(ZLIB_LIBRARIES "")
IF(NOT EXISTS "${ZLIB_INCLUDE_DIRS}/zlib.h") if(NOT EXISTS "${ZLIB_INCLUDE_DIRS}/zlib.h")
MESSAGE("Please specify a valid zlib include dir") message("Please specify a valid zlib include dir")
ENDIF(NOT EXISTS "${ZLIB_INCLUDE_DIRS}/zlib.h") endif(NOT EXISTS "${ZLIB_INCLUDE_DIRS}/zlib.h")
ENDIF(UNIX) endif(UNIX)
# set all include directories for in and out of source builds # set all include directories for in and out of source builds
include_directories( include_directories(
@ -20,23 +20,12 @@ include_directories(
${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}
) )
# include with QT_USE selected library parts
# INCLUDE(${QT_USE_FILE})
file(GLOB SRCS "*.c" "*.cpp") file(GLOB SRCS "*.c" "*.cpp")
file(GLOB PUBLIC_HEADERS "*.h") file(GLOB PUBLIC_HEADERS "*.h")
# Static link! # Static link!
ADD_DEFINITIONS(-DQUAZIP_STATIC) add_definitions(-DQUAZIP_STATIC)
#qt5_wrap_cpp(MOC_SRCS ${PUBLIC_HEADERS})
#set(SRCS ${SRCS} ${MOC_SRCS})
#set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_library(quazip STATIC ${SRCS}) add_library(quazip STATIC ${SRCS})
QT5_USE_MODULES(quazip Core) qt5_use_modules(quazip Core)
target_link_libraries(quazip ${ZLIB_LIBRARIES}) target_link_libraries(quazip ${ZLIB_LIBRARIES})
#install(FILES ${PUBLIC_HEADERS} DESTINATION include/quazip)
#install(TARGETS quazip LIBRARY DESTINATION ${LIB_DESTINATION} ARCHIVE DESTINATION ${LIB_DESTINATION} RUNTIME DESTINATION ${LIB_DESTINATION})

View File

@ -9,28 +9,28 @@ include_directories(${Qt5Base_INCLUDE_DIRS})
include(UseCXX11) include(UseCXX11)
include(Coverage) include(Coverage)
SET(LIBSETTINGS_SOURCES set(LIBSETTINGS_SOURCES
libsettings_config.h libsettings_config.h
inifile.h inifile.h
inifile.cpp inifile.cpp
settingsobject.h settingsobject.h
settingsobject.cpp settingsobject.cpp
inisettingsobject.h inisettingsobject.h
inisettingsobject.cpp inisettingsobject.cpp
setting.h setting.h
setting.cpp setting.cpp
overridesetting.h overridesetting.h
overridesetting.cpp overridesetting.cpp
) )
# Set the include dir path. # Set the include dir path.
SET(LIBSETTINGS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE) set(LIBSETTINGS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE)
# Static link! # Static link!
ADD_DEFINITIONS(-DLIBSETTINGS_STATIC) add_definitions(-DLIBSETTINGS_STATIC)
add_definitions(-DLIBSETTINGS_LIBRARY) add_definitions(-DLIBSETTINGS_LIBRARY)

View File

@ -8,37 +8,35 @@ find_package(Qt5Core REQUIRED)
# Include Qt headers. # Include Qt headers.
include_directories(${Qt5Base_INCLUDE_DIRS}) include_directories(${Qt5Base_INCLUDE_DIRS})
# include_directories(${Qt5Network_INCLUDE_DIRS})
SET(LIBUTIL_SOURCES set(LIBUTIL_SOURCES
include/libutil_config.h include/libutil_config.h
include/pathutils.h include/pathutils.h
src/pathutils.cpp src/pathutils.cpp
include/osutils.h include/osutils.h
include/userutils.h include/userutils.h
src/userutils.cpp src/userutils.cpp
include/cmdutils.h include/cmdutils.h
src/cmdutils.cpp src/cmdutils.cpp
include/modutils.h include/modutils.h
src/modutils.cpp src/modutils.cpp
) )
# Set the include dir path. # Set the include dir path.
SET(LIBUTIL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE) set(LIBUTIL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
# Static link! # Static link!
ADD_DEFINITIONS(-DLIBUTIL_STATIC) add_definitions(-DLIBUTIL_STATIC)
add_definitions(-DLIBUTIL_LIBRARY) add_definitions(-DLIBUTIL_LIBRARY)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_library(libUtil STATIC ${LIBUTIL_SOURCES}) add_library(libUtil STATIC ${LIBUTIL_SOURCES})
# qt5_use_modules(libUtil Core Network)
qt5_use_modules(libUtil Core) qt5_use_modules(libUtil Core)
target_link_libraries(libUtil) target_link_libraries(libUtil)

View File

@ -8,22 +8,22 @@ option(XZ_BUILD_MINIDEC "Build a tiny utility that decompresses xz streams" OFF)
set(CMAKE_C_FLAGS "-std=c99") set(CMAKE_C_FLAGS "-std=c99")
include_directories(include) include_directories(include)
SET(XZ_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE) set(XZ_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
# See include/xz.h for manual feature configuration # See include/xz.h for manual feature configuration
# tweak this list and xz.h to fit your needs # tweak this list and xz.h to fit your needs
set(XZ_SOURCES set(XZ_SOURCES
include/xz.h include/xz.h
src/xz_config.h src/xz_config.h
src/xz_crc32.c src/xz_crc32.c
src/xz_crc64.c src/xz_crc64.c
src/xz_dec_lzma2.c src/xz_dec_lzma2.c
src/xz_dec_stream.c src/xz_dec_stream.c
src/xz_lzma2.h src/xz_lzma2.h
src/xz_private.h src/xz_private.h
src/xz_stream.h src/xz_stream.h
# src/xz_dec_bcj.c # src/xz_dec_bcj.c
) )
# TODO: look into what would be needed for plain old lzma # TODO: look into what would be needed for plain old lzma

View File

@ -1,4 +1,4 @@
FILE(GLOB_RECURSE QTPLUGINS "${CMAKE_INSTALL_PREFIX}/@PLUGIN_DEST_DIR@/*@CMAKE_SHARED_LIBRARY_SUFFIX@") file(GLOB_RECURSE QTPLUGINS "${CMAKE_INSTALL_PREFIX}/@PLUGIN_DEST_DIR@/*@CMAKE_SHARED_LIBRARY_SUFFIX@")
function(gp_resolved_file_type_override resolved_file type_var) function(gp_resolved_file_type_override resolved_file type_var)
if(resolved_file MATCHES "^/usr/lib/libQt") if(resolved_file MATCHES "^/usr/lib/libQt")
message("resolving ${resolved_file} as other") message("resolving ${resolved_file} as other")
@ -6,12 +6,12 @@ function(gp_resolved_file_type_override resolved_file type_var)
elseif(resolved_file MATCHES "^/usr/lib(.+)?/libxcb") elseif(resolved_file MATCHES "^/usr/lib(.+)?/libxcb")
message("resolving ${resolved_file} as other") message("resolving ${resolved_file} as other")
set(${type_var} other PARENT_SCOPE) set(${type_var} other PARENT_SCOPE)
endif() endif()
endfunction() endfunction()
set(gp_tool "@CMAKE_GP_TOOL@") set(gp_tool "@CMAKE_GP_TOOL@")
set(gp_cmd_paths ${gp_cmd_paths} set(gp_cmd_paths ${gp_cmd_paths}
"@CMAKE_GP_CMD_PATHS@" "@CMAKE_GP_CMD_PATHS@"
) )
include(BundleUtilities) include(BundleUtilities)

View File

@ -6,18 +6,18 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include_directories(depends) include_directories(depends)
if (WIN32) if(WIN32)
include_directories(depends/win32cpp) include_directories(depends/win32cpp)
# static all the things. The updater must have no dependencies, or it will fail. # static all the things. The updater must have no dependencies, or it will fail.
if (MINGW) if(MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++ -static") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++ -static")
#set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s") #set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s")
#set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc -static-libstdc++ -s") #set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc -static-libstdc++ -s")
endif() endif()
if(MSVC) if(MSVC)
# - Link the updater binary statically with the Visual C++ runtime # - Link the updater binary statically with the Visual C++ runtime
# so that the executable can function standalone. # so that the executable can function standalone.
# - Enable PDB generation for release builds # - Enable PDB generation for release builds
@ -27,14 +27,14 @@ if (WIN32)
set(CMAKE_CXX_FLAGS_RELEASE "/MT /Zi /O2 /Ob2 /D NDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "/MT /Zi /O2 /Ob2 /D NDEBUG")
set(CMAKE_C_FLAGS_RELEASE "/MT /Zi /O2 /Ob2 /D NDEBUG") set(CMAKE_C_FLAGS_RELEASE "/MT /Zi /O2 /Ob2 /D NDEBUG")
remove_definitions(-DUNICODE -D_UNICODE) remove_definitions(-DUNICODE -D_UNICODE)
endif() endif()
else() else()
# optimize for reduced code size # optimize for reduced code size
set(CMAKE_CXX_FLAGS_RELEASE "-Os") set(CMAKE_CXX_FLAGS_RELEASE "-Os")
set(CMAKE_C_FLAGS_RELEASE "-Os") set(CMAKE_C_FLAGS_RELEASE "-Os")
endif() endif()
if (APPLE) if(APPLE)
# Build the updater as a dual 32/64bit binary. If only one architecture # Build the updater as a dual 32/64bit binary. If only one architecture
# is required, removing the other architecture will reduce the size # is required, removing the other architecture will reduce the size
# of the updater binary # of the updater binary

View File

@ -4,79 +4,76 @@ add_subdirectory(tests)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
include(GenerateCppResourceFile) include(GenerateCppResourceFile)
set (UPDATER_SOURCES set(UPDATER_SOURCES
AppInfo.cpp AppInfo.cpp
AppInfo.h AppInfo.h
DirIterator.cpp DirIterator.cpp
DirIterator.h DirIterator.h
FileUtils.cpp FileUtils.cpp
FileUtils.h FileUtils.h
Log.cpp Log.cpp
Log.h Log.h
ProcessUtils.cpp ProcessUtils.cpp
ProcessUtils.h ProcessUtils.h
StandardDirs.cpp StandardDirs.cpp
StandardDirs.h StandardDirs.h
UpdateDialog.cpp UpdateDialog.cpp
UpdateInstaller.cpp UpdateInstaller.cpp
UpdateInstaller.h UpdateInstaller.h
UpdateScript.cpp UpdateScript.cpp
UpdateScript.h UpdateScript.h
UpdaterOptions.cpp UpdaterOptions.cpp
UpdaterOptions.h UpdaterOptions.h
) )
add_definitions(-DTIXML_USE_STL) add_definitions(-DTIXML_USE_STL)
if (WIN32) if(WIN32)
set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogWin32.cpp UpdateDialogWin32.h) set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogWin32.cpp UpdateDialogWin32.h)
endif() endif()
if (UNIX) if(UNIX)
set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogAscii.cpp UpdateDialogAscii.h) set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogAscii.cpp UpdateDialogAscii.h)
add_definitions(-Wall -Wconversion) add_definitions(-Wall -Wconversion)
if (APPLE) if(APPLE)
set(MAC_DOCK_ICON_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/mac_dock_icon.cpp) set(MAC_DOCK_ICON_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/mac_dock_icon.cpp)
set(MAC_INFO_PLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/mac_info_plist.cpp) set(MAC_INFO_PLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/mac_info_plist.cpp)
generate_cpp_resource_file(resource_macdockicon ${CMAKE_CURRENT_SOURCE_DIR}/resources/mac.icns ${MAC_DOCK_ICON_CPP_FILE}) generate_cpp_resource_file(resource_macdockicon ${CMAKE_CURRENT_SOURCE_DIR}/resources/mac.icns ${MAC_DOCK_ICON_CPP_FILE})
generate_cpp_resource_file(resource_macplist ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist ${MAC_INFO_PLIST_FILE}) generate_cpp_resource_file(resource_macplist ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist ${MAC_INFO_PLIST_FILE})
set(UPDATER_SOURCES ${UPDATER_SOURCES} set(UPDATER_SOURCES ${UPDATER_SOURCES}
MacBundle.h MacBundle.h
MacBundle.cpp MacBundle.cpp
StandardDirs.mm StandardDirs.mm
StlSymbolsLeopard.cpp StlSymbolsLeopard.cpp
UpdateDialogCocoa.mm UpdateDialogCocoa.mm
UpdateDialogCocoa.h UpdateDialogCocoa.h
mac_dock_icon.cpp mac_dock_icon.cpp
mac_info_plist.cpp mac_info_plist.cpp
) )
else() # linuxes and other similar systems else() # linuxes and other similar systems
find_package(GTK2 REQUIRED gtk) find_package(GTK2 REQUIRED gtk)
include_directories(${GTK2_INCLUDE_DIRS}) include_directories(${GTK2_INCLUDE_DIRS})
add_library(updatergtk SHARED UpdateDialogGtk.cpp UpdateDialogGtk.h) add_library(updatergtk SHARED UpdateDialogGtk.cpp UpdateDialogGtk.h)
target_link_libraries(updatergtk ${GTK2_LIBRARIES}) target_link_libraries(updatergtk ${GTK2_LIBRARIES})
# embed the GTK helper library into the updater binary. # embed the GTK helper library into the updater binary.
# At runtime it will be extracted and loaded if the # At runtime it will be extracted and loaded if the
# GTK libraries are available # GTK libraries are available
get_property(GTK_UPDATER_LIB TARGET updatergtk PROPERTY LOCATION) get_property(GTK_UPDATER_LIB TARGET updatergtk PROPERTY LOCATION)
set(GTK_BIN_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/libupdatergtk.cpp) set(GTK_BIN_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/libupdatergtk.cpp)
generate_cpp_resource_file(resource_updatergtk ${GTK_UPDATER_LIB} ${GTK_BIN_CPP_FILE}) generate_cpp_resource_file(resource_updatergtk ${GTK_UPDATER_LIB} ${GTK_BIN_CPP_FILE})
add_dependencies(resource_updatergtk updatergtk) add_dependencies(resource_updatergtk updatergtk)
set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogGtkFactory.cpp UpdateDialogGtkFactory.h ${GTK_BIN_CPP_FILE}) set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogGtkFactory.cpp UpdateDialogGtkFactory.h ${GTK_BIN_CPP_FILE})
endif() endif()
endif() endif()
add_library(updatershared STATIC ${UPDATER_SOURCES}) add_library(updatershared STATIC ${UPDATER_SOURCES})
target_link_libraries(updatershared target_link_libraries(updatershared anyoption tinyxml)
anyoption
tinyxml
)
if (UNIX) if(UNIX)
if (APPLE) if(APPLE)
find_library(COCOA_LIBRARY Cocoa) find_library(COCOA_LIBRARY Cocoa)
find_library(SECURITY_LIBRARY Security) find_library(SECURITY_LIBRARY Security)
target_link_libraries(updatershared ${SECURITY_LIBRARY} ${COCOA_LIBRARY}) target_link_libraries(updatershared ${SECURITY_LIBRARY} ${COCOA_LIBRARY})
@ -86,36 +83,34 @@ if (UNIX)
target_link_libraries(updatershared pthread dl) target_link_libraries(updatershared pthread dl)
endif() endif()
if (WIN32) if(WIN32)
set(EXE_FLAGS WIN32 resources/updater.rc) set(EXE_FLAGS WIN32 resources/updater.rc)
endif() endif()
add_executable(updater ${EXE_FLAGS} main.cpp) add_executable(updater ${EXE_FLAGS} main.cpp)
target_link_libraries(updater target_link_libraries(updater updatershared)
updatershared
)
#### Updater Executable #### #### Updater Executable ####
IF(WIN32) if(WIN32)
INSTALL(TARGETS updater install(TARGETS updater
BUNDLE DESTINATION . COMPONENT Runtime BUNDLE DESTINATION . COMPONENT Runtime
LIBRARY DESTINATION . COMPONENT Runtime LIBRARY DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION . COMPONENT Runtime RUNTIME DESTINATION . COMPONENT Runtime
) )
ENDIF() endif()
IF(UNIX) if(UNIX)
IF(APPLE) if(APPLE)
INSTALL(TARGETS updater install(TARGETS updater
BUNDLE DESTINATION . COMPONENT Runtime BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime
) )
ELSE() else()
INSTALL(TARGETS updater install(TARGETS updater
BUNDLE DESTINATION . COMPONENT Runtime BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION bin COMPONENT Runtime RUNTIME DESTINATION bin COMPONENT Runtime
) )
ENDIF() endif()
ENDIF() endif()

View File

@ -1,8 +1,8 @@
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..")
if (APPLE) if(APPLE)
set(HELPER_SHARED_SOURCES ../StlSymbolsLeopard.cpp) set(HELPER_SHARED_SOURCES ../StlSymbolsLeopard.cpp)
endif() endif()
# # Create helper binaries for unit tests # # Create helper binaries for unit tests
@ -17,14 +17,14 @@ endif()
# Install data files required by unit tests # Install data files required by unit tests
set(TEST_FILES set(TEST_FILES
file_list.xml file_list.xml
) )
foreach(TEST_FILE ${TEST_FILES}) foreach(TEST_FILE ${TEST_FILES})
execute_process( execute_process(
COMMAND COMMAND
"${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE}" "${CMAKE_CURRENT_BINARY_DIR}"
) )
endforeach() endforeach()
# Add unit test binaries # Add unit test binaries
@ -32,13 +32,13 @@ macro(ADD_UPDATER_TEST CLASS)
set(TEST_TARGET updater_${CLASS}) set(TEST_TARGET updater_${CLASS})
unset(srcs) unset(srcs)
list(APPEND srcs ${CLASS}.cpp) list(APPEND srcs ${CLASS}.cpp)
if (WIN32) if(WIN32)
list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/test.rc) list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/test.rc)
endif() endif()
add_executable(${TEST_TARGET} ${srcs}) add_executable(${TEST_TARGET} ${srcs})
target_link_libraries(${TEST_TARGET} updatershared) target_link_libraries(${TEST_TARGET} updatershared)
add_test(NAME ${TEST_TARGET} COMMAND ${TEST_TARGET}) add_test(NAME ${TEST_TARGET} COMMAND ${TEST_TARGET})
if (APPLE) if(APPLE)
set_target_properties(${TEST_TARGET} PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa") set_target_properties(${TEST_TARGET} PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa")
endif() endif()
endmacro() endmacro()

View File

@ -8,7 +8,7 @@ macro(add_unit_test name)
unset(srcs) unset(srcs)
foreach(arg ${testname} ${ARGN}) foreach(arg ${testname} ${ARGN})
list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/${arg}) list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
if (WIN32) if(WIN32)
list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/test.rc) list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/test.rc)
endif() endif()
endforeach() endforeach()
@ -30,19 +30,19 @@ add_unit_test(DownloadUpdateTask tst_DownloadUpdateTask.cpp)
# Tests END # # Tests END #
set(COVERAGE_SOURCE_DIRS set(COVERAGE_SOURCE_DIRS
${MMC_SRC}/logic/* ${MMC_SRC}/logic/*
${MMC_SRC}/logic/auth/* ${MMC_SRC}/logic/auth/*
${MMC_SRC}/logic/auth/flows/* ${MMC_SRC}/logic/auth/flows/*
${MMC_SRC}/logic/lists/* ${MMC_SRC}/logic/lists/*
${MMC_SRC}/logic/net/* ${MMC_SRC}/logic/net/*
${MMC_SRC}/logic/tasks/* ${MMC_SRC}/logic/tasks/*
${MMC_SRC}/gui/* ${MMC_SRC}/gui/*
${MMC_SRC}/gui/dialogs/* ${MMC_SRC}/gui/dialogs/*
${MMC_SRC}/gui/widgets/* ${MMC_SRC}/gui/widgets/*
${MMC_SRC}/depends/settings/include/* ${MMC_SRC}/depends/settings/include/*
${MMC_SRC}/depends/settings/src/* ${MMC_SRC}/depends/settings/src/*
${MMC_SRC}/depends/util/include/* ${MMC_SRC}/depends/util/include/*
${MMC_SRC}/depends/util/src/* ${MMC_SRC}/depends/util/src/*
) )
if(MultiMC_CODE_COVERAGE) if(MultiMC_CODE_COVERAGE)
@ -51,7 +51,7 @@ if(MultiMC_CODE_COVERAGE)
foreach(test ${MultiMC_TESTS}) foreach(test ${MultiMC_TESTS})
add_custom_target(MultiMC_RUN_TEST_${test} add_custom_target(MultiMC_RUN_TEST_${test}
COMMAND lcov -d ${CMAKE_CURRENT_BINARY_DIR} -z -q # clean test COMMAND lcov -d ${CMAKE_CURRENT_BINARY_DIR} -z -q # clean test
&& lcov -d ${MMC_BIN} -z -q # clean common && lcov -d ${MMC_BIN} -z -q # clean common
&& lcov -d ${MMC_BIN}/depends/settings/CMakeFiles/libSettings.dir -z -q # clean settings && lcov -d ${MMC_BIN}/depends/settings/CMakeFiles/libSettings.dir -z -q # clean settings
&& lcov -d ${MMC_BIN}/depends/utils/CMakeFiles/libUtil.dir -z -q # clean utils && lcov -d ${MMC_BIN}/depends/utils/CMakeFiles/libUtil.dir -z -q # clean utils
@ -64,23 +64,23 @@ if(MultiMC_CODE_COVERAGE)
-a coverage_${test}.info -a coverage_common.info -a coverage_settings.info -a coverage_utils.info -a coverage_${test}.info -a coverage_common.info -a coverage_settings.info -a coverage_utils.info
-o coverage_${test}-combined.info # combine test and common -o coverage_${test}-combined.info # combine test and common
&& lcov -q --checksum -b ${MMC_SRC} --list-full-path --extract coverage_${test}-combined.info ${COVERAGE_SOURCE_DIRS} -o coverage_${test}-stripped.info # strip && lcov -q --checksum -b ${MMC_SRC} --list-full-path --extract coverage_${test}-combined.info ${COVERAGE_SOURCE_DIRS} -o coverage_${test}-stripped.info # strip
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
VERBATIM VERBATIM
DEPENDS ${test} DEPENDS ${test}
COMMENT "Running ${test}..." COMMENT "Running ${test}..."
) )
list(APPEND MultiMC_TEST_COVERAGE_FILES coverage_${test}-stripped.info) list(APPEND MultiMC_TEST_COVERAGE_FILES coverage_${test}-stripped.info)
list(APPEND MultiMC_RUN_TESTS MultiMC_RUN_TEST_${test}) list(APPEND MultiMC_RUN_TESTS MultiMC_RUN_TEST_${test})
endforeach(test) endforeach(test)
add_custom_target(MultiMC_GENERATE_COVERAGE add_custom_target(MultiMC_GENERATE_COVERAGE
DEPENDS ${MultiMC_RUN_TESTS} DEPENDS ${MultiMC_RUN_TESTS}
COMMENT "Generating coverage files..." COMMENT "Generating coverage files..."
) )
add_custom_target(MultiMC_GENERATE_COVERAGE_HTML add_custom_target(MultiMC_GENERATE_COVERAGE_HTML
COMMAND genhtml -t "MultiMC 5 Test Coverage" --num-spaces 4 --demangle-cpp --legend -o ${MMC_SRC}/html/coverage ${MultiMC_TEST_COVERAGE_FILES} COMMAND genhtml -t "MultiMC 5 Test Coverage" --num-spaces 4 --demangle-cpp --legend -o ${MMC_SRC}/html/coverage ${MultiMC_TEST_COVERAGE_FILES}
DEPENDS MultiMC_GENERATE_COVERAGE DEPENDS MultiMC_GENERATE_COVERAGE
COMMENT "Generating test coverage html..." COMMENT "Generating test coverage html..."
) )
add_custom_target(MultiMC_RUN_TESTS DEPENDS MultiMC_GENERATE_COVERAGE_HTML) add_custom_target(MultiMC_RUN_TESTS DEPENDS MultiMC_GENERATE_COVERAGE_HTML)
endif(MultiMC_CODE_COVERAGE) endif(MultiMC_CODE_COVERAGE)

View File

@ -9,8 +9,8 @@ qt5_add_translation(TRANSLATION_QM ${TRANSLATION_FILES})
add_custom_target(translations_update DEPENDS ${TRANSLATION_MESSAGES}) add_custom_target(translations_update DEPENDS ${TRANSLATION_MESSAGES})
add_custom_target(translations DEPENDS ${TRANSLATION_QM}) add_custom_target(translations DEPENDS ${TRANSLATION_QM})
IF(APPLE AND UNIX) ## OSX if(APPLE AND UNIX) ## OSX
install(FILES ${TRANSLATION_QM} DESTINATION MultiMC.app/Contents/MacOS/translations) install(FILES ${TRANSLATION_QM} DESTINATION MultiMC.app/Contents/MacOS/translations)
ELSE() else()
install(FILES ${TRANSLATION_QM} DESTINATION translations) install(FILES ${TRANSLATION_QM} DESTINATION translations)
ENDIF() endif()