summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-04-07 17:44:52 +0200
committerJan Dalheimer <jan@dalheimer.de>2014-04-07 17:44:52 +0200
commit3cd2b898e5bbf00d22647b2b114502c0a8076495 (patch)
treecff8e7bcd5c210c07011ffafaede79dc00b69082
parentdd7b6642a3b171734126b6b4a14236cfe6406fcf (diff)
parent17d4947b30f00a347d7fb8648040271e4b65f966 (diff)
downloadMultiMC-3cd2b898e5bbf00d22647b2b114502c0a8076495.tar
MultiMC-3cd2b898e5bbf00d22647b2b114502c0a8076495.tar.gz
MultiMC-3cd2b898e5bbf00d22647b2b114502c0a8076495.tar.lz
MultiMC-3cd2b898e5bbf00d22647b2b114502c0a8076495.tar.xz
MultiMC-3cd2b898e5bbf00d22647b2b114502c0a8076495.zip
Merge remote-tracking branch 'origin/develop' into feature_cmake_style
Conflicts: CMakeLists.txt
-rw-r--r--CMakeLists.txt56
-rw-r--r--cmake/Coverage.cmake13
-rw-r--r--cmake/Coverity.cmake35
-rw-r--r--cmake/GitFunctions.cmake37
-rw-r--r--cmake/QMakeQuery.cmake14
-rw-r--r--cmake/UseCXX11.cmake13
-rw-r--r--depends/settings/CMakeLists.txt10
-rw-r--r--depends/util/CMakeLists.txt24
8 files changed, 127 insertions, 75 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d463ce8a..0278b7cd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,19 +33,11 @@ endif()
set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${PROJECT_BINARY_DIR}/jars)
######## Set compiler flags ########
-IF(APPLE)
- message(STATUS "Using APPLE CMAKE_CXX_FLAGS")
- 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++11 -Wall")
-ELSEIF(MINGW)
- MESSAGE(STATUS "Using MINGW CMAKE_CXX_FLAGS")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall")
-ENDIF()
-
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror=return-type")
+include(UseCXX11)
+include(Coverage)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror=return-type")
+
################################ 3rd Party Libs ################################
# Find the required Qt parts
@@ -65,15 +57,7 @@ include_directories(
)
# 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)
-
+include(QMakeQuery)
query_qmake(QT_INSTALL_PLUGINS QT_PLUGINS_DIR)
query_qmake(QT_INSTALL_IMPORTS QT_IMPORTS_DIR)
query_qmake(QT_INSTALL_LIBS QT_LIBS_DIR)
@@ -183,29 +167,9 @@ endif()
add_custom_target(version echo "Version: ${MultiMC_VERSION_STRING}")
#### Check the current Git commit
-execute_process(COMMAND git rev-parse HEAD
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- RESULT_VARIABLE GIT_COMMIT_CHECK_RESULTVAR
- OUTPUT_VARIABLE GIT_COMMIT_CHECK_OUTVAR
- OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
-IF(GIT_COMMIT_CHECK_RESULTVAR EQUAL 0)
- SET(MultiMC_GIT_COMMIT "${GIT_COMMIT_CHECK_OUTVAR}")
- MESSAGE(STATUS "Git commit: ${MultiMC_GIT_COMMIT}")
-ELSE()
- SET(MultiMC_GIT_COMMIT "Unknown")
- MESSAGE(STATUS "Failed to check Git commit. ${GIT_COMMIT_CHECK_RESULTVAR}")
-ENDIF()
-
-OPTION(MultiMC_CODE_COVERAGE "Compiles for code coverage" OFF)
-IF(MultiMC_CODE_COVERAGE)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage")
- SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 --coverage")
- SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -O0 --coverage")
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O0 --coverage")
-ENDIF(MultiMC_CODE_COVERAGE)
+include(GitFunctions)
+git_run(COMMAND rev-parse HEAD DEFAULT "Unknown" OUTPUT_VAR MultiMC_GIT_COMMIT)
+message(STATUS "Git commit: ${MultiMC_GIT_COMMIT}")
######## Configure header ########
configure_file("${PROJECT_SOURCE_DIR}/BuildConfig.cpp.in" "${PROJECT_BINARY_DIR}/BuildConfig.cpp")
@@ -790,6 +754,8 @@ endif()
include(CPack)
+include(Coverity)
+
include_directories(${PROJECT_BINARY_DIR}/include)
# Translations
diff --git a/cmake/Coverage.cmake b/cmake/Coverage.cmake
new file mode 100644
index 00000000..28efbf1c
--- /dev/null
+++ b/cmake/Coverage.cmake
@@ -0,0 +1,13 @@
+if(__COVERAGE_CMAKE__)
+ return()
+endif()
+set(__COVERAGE_CMAKE__ TRUE)
+
+if(MultiMC_CODE_COVERAGE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 --coverage")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 --coverage")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 --coverage")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O0 --coverage")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O0 --coverage")
+ set(CMAKE_BUILD_TYPE "Debug")
+endif(MultiMC_CODE_COVERAGE)
diff --git a/cmake/Coverity.cmake b/cmake/Coverity.cmake
new file mode 100644
index 00000000..899d9852
--- /dev/null
+++ b/cmake/Coverity.cmake
@@ -0,0 +1,35 @@
+if(__COVERITY_CMAKE__)
+ return()
+endif()
+set(__COVERITY_CMAKE__ TRUE)
+
+include(GitFunctions)
+
+git_run(COMMAND config --get user.email DEFAULT "" OUTPUT_VAR GIT_EMAIL)
+git_run(COMMAND describe DEFAULT "" OUTPUT_VAR GIT_VERSION)
+
+set(MultiMC_COVERITY_TOKEN "" CACHE STRING "Coverity access token")
+set(MultiMC_COVERITY_EMAIL "${GIT_EMAIL}" CACHE STRING "Coverity email")
+
+set(MultiMC_COVERITY_TOOLS_DIR "${CMAKE_BINARY_DIR}/coverity_tools" CACHE PATH "Path to the coverity tools")
+
+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 "")
+ add_custom_target(coverity_configure
+ COMMAND ${MultiMC_COVERITY_TOOLS_DIR}/bin/cov-configure --comptype gcc --compiler ${CMAKE_C_COMPILER}
+ )
+ add_custom_target(coverity_create_tarball
+ 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 "Creating tarball..." && ${CMAKE_COMMAND} -E tar cfz multimc_coverity.tgz cov-int/
+ COMMENT "Creating coverity build..."
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ )
+ 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
+ DEPENDS coverity_create_tarball
+ COMMENT "Uploading to coverity..."
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ )
+endif()
diff --git a/cmake/GitFunctions.cmake b/cmake/GitFunctions.cmake
new file mode 100644
index 00000000..e0868725
--- /dev/null
+++ b/cmake/GitFunctions.cmake
@@ -0,0 +1,37 @@
+if(__GITFUNCTIONS_CMAKE__)
+ return()
+endif()
+set(__GITFUNCTIONS_CMAKE__ TRUE)
+
+find_package(Git QUIET)
+
+include(CMakeParseArguments)
+
+if(GIT_FOUND)
+ function(git_run)
+ set(oneValueArgs OUTPUT_VAR DEFAULT)
+ set(multiValueArgs COMMAND)
+ cmake_parse_arguments(GIT_RUN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ execute_process(COMMAND ${GIT_EXECUTABLE} ${GIT_RUN_COMMAND}
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE GIT_RESULTVAR
+ OUTPUT_VARIABLE GIT_OUTVAR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ if(GIT_RESULTVAR EQUAL 0)
+ set(${GIT_RUN_OUTPUT_VAR} "${GIT_OUTVAR}" PARENT_SCOPE)
+ else()
+ set(${GIT_RUN_OUTPUT_VAR} ${GIT_RUN_DEFAULT})
+ message(STATUS "Failed to run Git: ${GIT_OUTVAR}")
+ endif()
+ endfunction()
+else()
+ function(git_run)
+ set(oneValueArgs OUTPUT_VAR DEFAULT)
+ set(multiValueArgs COMMAND)
+ cmake_parse_arguments(GIT_RUN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ set(${GIT_RUN_OUTPUT_VAR} ${GIT_RUN_DEFAULT})
+ endfunction(git_run)
+endif()
diff --git a/cmake/QMakeQuery.cmake b/cmake/QMakeQuery.cmake
new file mode 100644
index 00000000..bf0fe967
--- /dev/null
+++ b/cmake/QMakeQuery.cmake
@@ -0,0 +1,14 @@
+if(__QMAKEQUERY_CMAKE__)
+ return()
+endif()
+set(__QMAKEQUERY_CMAKE__ TRUE)
+
+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)
diff --git a/cmake/UseCXX11.cmake b/cmake/UseCXX11.cmake
new file mode 100644
index 00000000..e94de2bb
--- /dev/null
+++ b/cmake/UseCXX11.cmake
@@ -0,0 +1,13 @@
+if(__USECXX11_CMAKE__)
+ return()
+endif()
+set(__USECXX11_CMAKE__ TRUE)
+
+if(APPLE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+elseif(UNIX)
+ # assume GCC, add C++0x/C++11 stuff
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+elseif(MINGW)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
+endif()
diff --git a/depends/settings/CMakeLists.txt b/depends/settings/CMakeLists.txt
index 868b31e6..aa44b731 100644
--- a/depends/settings/CMakeLists.txt
+++ b/depends/settings/CMakeLists.txt
@@ -6,6 +6,8 @@ find_package(Qt5Core REQUIRED)
# Include Qt headers.
include_directories(${Qt5Base_INCLUDE_DIRS})
+include(UseCXX11)
+include(Coverage)
set(LIBSETTINGS_SOURCES
libsettings_config.h
@@ -34,14 +36,6 @@ add_definitions(-DLIBSETTINGS_LIBRARY)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-IF(MultiMC_CODE_COVERAGE)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage")
- SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 --coverage")
- SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -O0 --coverage")
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O0 --coverage")
-ENDIF(MultiMC_CODE_COVERAGE)
-
add_library(libSettings STATIC ${LIBSETTINGS_SOURCES})
qt5_use_modules(libSettings Core)
target_link_libraries(libSettings)
diff --git a/depends/util/CMakeLists.txt b/depends/util/CMakeLists.txt
index 969c4a78..137d232e 100644
--- a/depends/util/CMakeLists.txt
+++ b/depends/util/CMakeLists.txt
@@ -1,19 +1,7 @@
project(libUtil)
-######## Set compiler flags ########
-IF(APPLE)
- # assume clang 4.1.0+, add C++0x/C++11 stuff
- message(STATUS "Using APPLE CMAKE_CXX_FLAGS")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-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")
-ELSEIF(MINGW)
- MESSAGE(STATUS "Using MINGW CMAKE_CXX_FLAGS")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
-ENDIF()
-
+include(UseCXX11)
+include(Coverage)
# Find Qt
find_package(Qt5Core REQUIRED)
@@ -49,14 +37,6 @@ add_definitions(-DLIBUTIL_LIBRARY)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-IF(MultiMC_CODE_COVERAGE)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage")
- SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 --coverage")
- SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -O0 --coverage")
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O0 --coverage")
-ENDIF(MultiMC_CODE_COVERAGE)
-
add_library(libUtil STATIC ${LIBUTIL_SOURCES})
qt5_use_modules(libUtil Core)
target_link_libraries(libUtil)