diff --git a/3rdparty/singleapplication/CMakeLists.txt b/3rdparty/singleapplication/CMakeLists.txt index 2a95bbc2..7ef92b01 100644 --- a/3rdparty/singleapplication/CMakeLists.txt +++ b/3rdparty/singleapplication/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.0) include(CheckIncludeFiles) include(CheckFunctionExists) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -U__STRICT_ANSI__ -Wall -Wextra -Wpedantic -Woverloaded-virtual -fpermissive") - -if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") -endif() - if(CMAKE_VERSION VERSION_GREATER 3.0) check_function_exists(geteuid HAVE_GETEUID) check_function_exists(getpwuid HAVE_GETPWUID) @@ -19,14 +11,15 @@ endif() set(SINGLEAPP-SOURCES singleapplication.cpp singleapplication_p.cpp) set(SINGLEAPP-MOC-HEADERS singleapplication.h singleapplication_p.h) QT5_WRAP_CPP(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS}) -ADD_LIBRARY(singleapplication STATIC ${SINGLEAPP-SOURCES} ${SINGLEAPP-SOURCES-MOC}) +add_library(singleapplication STATIC ${SINGLEAPP-SOURCES} ${SINGLEAPP-SOURCES-MOC}) target_link_libraries(singleapplication Qt5::Core Qt5::Widgets Qt5::Network) set(SINGLECOREAPP-SOURCES singlecoreapplication.cpp singlecoreapplication_p.cpp) set(SINGLECOREAPP-MOC-HEADERS singlecoreapplication.h singlecoreapplication_p.h) QT5_WRAP_CPP(SINGLECOREAPP-SOURCES-MOC ${SINGLECOREAPP-MOC-HEADERS}) -ADD_LIBRARY(singlecoreapplication STATIC ${SINGLECOREAPP-SOURCES} ${SINGLECOREAPP-SOURCES-MOC}) +add_library(singlecoreapplication STATIC ${SINGLECOREAPP-SOURCES} ${SINGLECOREAPP-SOURCES-MOC}) target_link_libraries(singlecoreapplication Qt5::Core Qt5::Widgets Qt5::Network) configure_file(config.h.in "${CMAKE_CURRENT_BINARY_DIR}/config.h") + include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/3rdparty/taglib/CMakeLists.txt b/3rdparty/taglib/CMakeLists.txt index 6519e216..9eeda3bd 100644 --- a/3rdparty/taglib/CMakeLists.txt +++ b/3rdparty/taglib/CMakeLists.txt @@ -1,8 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -U__STRICT_ANSI__ -fpermissive -Wall -Woverloaded-virtual -Wno-sign-compare -Wno-delete-non-virtual-dtor") +cmake_minimum_required(VERSION 3.0) set(TAGLIB_SOVERSION_CURRENT 17) set(TAGLIB_SOVERSION_REVISION 0) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ccca7c5..e28e54ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,7 @@ -# Strawberry Music Player -# Copyright 2013, Jonas Kvinge -# -# Strawberry is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Strawberry is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Strawberry. If not, see . - project(strawberry) -cmake_minimum_required(VERSION 2.8.11) -if(CMAKE_VERSION VERSION_GREATER 3.0) - cmake_policy(SET CMP0054 NEW) -endif() + +cmake_minimum_required(VERSION 3.0) +cmake_policy(SET CMP0054 NEW) include(CheckCXXCompilerFlag) include(CheckCXXSourceRuns) @@ -32,6 +15,8 @@ include(cmake/Rpm.cmake) include(cmake/Deb.cmake) include(cmake/Dmg.cmake) +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(LINUX ON) endif() @@ -42,8 +27,49 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") set(OPENBSD ON) endif() +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(CMAKE_CXX_STANDARD 11) -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +list(APPEND COMPILE_OPTIONS + --std=c++11 + -U__STRICT_ANSI__ + -Wall + -Wextra + -Wpedantic + -Wunused + -Wshadow + -Wundef + -Wuninitialized + -Wredundant-decls + -Wcast-align + -Winit-self + -Woverloaded-virtual + -Wmissing-include-dirs + -Wmissing-declarations + -Wstrict-overflow=2 + -Wunused-parameter + -Wduplicated-branches + -Wduplicated-cond + -Wformat=2 + -Wdisabled-optimization + -Wunsafe-loop-optimizations + -Wno-sign-conversion + -Wno-old-style-cast + -fpermissive +) + +if(APPLE) + list(APPEND COMPILE_OPTIONS -Wno-unused-parameter) +endif() + +option(BUILD_WERROR "Build with -Werror" ON) +if(BUILD_WERROR) + list(APPEND COMPILE_OPTIONS -Werror) +endif(BUILD_WERROR) + +message(STATUS "COMPILE_OPTIONS: ${COMPILE_OPTIONS}") +add_compile_options(${COMPILE_OPTIONS}) if(${CMAKE_BUILD_TYPE} MATCHES "Release") add_definitions(-DNDEBUG) @@ -175,11 +201,10 @@ pkg_check_modules(TAGLIB taglib) # - Audio file detection by content. # - DSF and DSDIFF support # -if (TAGLIB_VERSION VERSION_GREATER 1.11.1) - option(USE_SYSTEM_TAGLIB "Use system taglib" ON) -else() - option(USE_SYSTEM_TAGLIB "Use system taglib" OFF) -endif() +# Some distros create their own version numbers for taglib so versions are not reliable anymore. +# Force to use our own copy of taglib unless USE_SYSTEM_TAGLIB is set. + +option(USE_SYSTEM_TAGLIB "Use system taglib" OFF) if (TAGLIB_FOUND AND USE_SYSTEM_TAGLIB) if (TAGLIB_VERSION VERSION_GREATER 1.11.1) message(STATUS "Using system taglib library") @@ -388,17 +413,14 @@ if(HAVE_XINE) XINE_ANALYZER) endif() -# Set up definitions and paths +# Set up definitions add_definitions(-DBOOST_BIND_NO_PLACEHOLDERS) add_definitions(${QT_DEFINITIONS}) +add_definitions(-DQT_STRICT_ITERATORS) add_definitions(-DQT_USE_QSTRINGBUILDER) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) -add_definitions(-DQT_NO_CAST_TO_ASCII -DQT_STRICT_ITERATORS) - -include_directories(${GLIB_INCLUDE_DIRS}) -include_directories(${GLIBCONFIG_INCLUDE_DIRS}) -include_directories(${TAGLIB_INCLUDE_DIRS}) +add_definitions(-DQT_NO_CAST_TO_ASCII) # Subdirectories add_subdirectory(src) diff --git a/ext/gstmoodbar/CMakeLists.txt b/ext/gstmoodbar/CMakeLists.txt index 8e90e0bd..d15ba7a0 100644 --- a/ext/gstmoodbar/CMakeLists.txt +++ b/ext/gstmoodbar/CMakeLists.txt @@ -1,15 +1,6 @@ -cmake_minimum_required(VERSION 2.8.11) - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -U__STRICT_ANSI__ -Wall -Wextra -Wpedantic -Woverloaded-virtual -fpermissive") - -if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") -endif() +cmake_minimum_required(VERSION 3.0) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) - include_directories(${GLIB_INCLUDE_DIRS}) include_directories(${GOBJECT_INCLUDE_DIRS}) include_directories(${GSTREAMER_INCLUDE_DIRS}) diff --git a/ext/libstrawberry-common/CMakeLists.txt b/ext/libstrawberry-common/CMakeLists.txt index 16be2735..7e50a1ee 100644 --- a/ext/libstrawberry-common/CMakeLists.txt +++ b/ext/libstrawberry-common/CMakeLists.txt @@ -1,13 +1,7 @@ -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -U__STRICT_ANSI__ -Wall -Wextra -Wpedantic -Woverloaded-virtual -fpermissive") +cmake_minimum_required(VERSION 3.0) -if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") -endif() - -include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_SOURCE_DIR}) include_directories(${CMAKE_SOURCE_DIR}/src) @@ -17,6 +11,8 @@ if (Backtrace_FOUND) include_directories(${Backtrace_INCLUDE_DIRS}) endif(Backtrace_FOUND) +include_directories(${GLIB_INCLUDE_DIRS}) +include_directories(${GLIBCONFIG_INCLUDE_DIRS}) include_directories(${PROTOBUF_INCLUDE_DIRS}) set(SOURCES @@ -41,18 +37,11 @@ endif(APPLE) qt5_wrap_cpp(MOC ${HEADERS}) -add_library(libstrawberry-common STATIC - ${SOURCES} - ${MOC} -) +add_library(libstrawberry-common STATIC ${SOURCES} ${MOC}) -if (Backtrace_FOUND) +if(Backtrace_FOUND) target_link_libraries(libstrawberry-common ${Backtrace_LIBRARIES}) -endif (Backtrace_FOUND) - -target_link_libraries(libstrawberry-common - ${TAGLIB_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} -) +endif(Backtrace_FOUND) +target_link_libraries(libstrawberry-common ${TAGLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(libstrawberry-common Qt5::Core Qt5::Network) diff --git a/ext/libstrawberry-tagreader/CMakeLists.txt b/ext/libstrawberry-tagreader/CMakeLists.txt index a6c4cdad..a754d103 100644 --- a/ext/libstrawberry-tagreader/CMakeLists.txt +++ b/ext/libstrawberry-tagreader/CMakeLists.txt @@ -1,10 +1,4 @@ -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -U__STRICT_ANSI__ -Wall -Wextra -Wpedantic -Woverloaded-virtual -fpermissive") - -if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") -endif() +cmake_minimum_required(VERSION 3.0) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) @@ -13,30 +7,12 @@ include_directories(${CMAKE_SOURCE_DIR}/src) include_directories(${CMAKE_BINARY_DIR}/src) include_directories(${PROTOBUF_INCLUDE_DIRS}) +include_directories(${TAGLIB_INCLUDE_DIRS}) -set(MESSAGES - tagreadermessages.proto -) - -set(SOURCES - fmpsparser.cpp - tagreader.cpp -) - -set(HEADERS -) - -qt5_wrap_cpp(MOC ${HEADERS}) +set(MESSAGES tagreadermessages.proto) +set(SOURCES fmpsparser.cpp tagreader.cpp) protobuf_generate_cpp(PROTO_SOURCES PROTO_HEADERS ${MESSAGES}) -add_library(libstrawberry-tagreader STATIC - ${PROTO_SOURCES} - ${SOURCES} - ${MOC} -) - -target_link_libraries(libstrawberry-tagreader - ${PROTOBUF_LIBRARY} - libstrawberry-common -) +add_library(libstrawberry-tagreader STATIC ${PROTO_SOURCES} ${SOURCES}) +target_link_libraries(libstrawberry-tagreader ${PROTOBUF_LIBRARY} libstrawberry-common) diff --git a/ext/strawberry-tagreader/CMakeLists.txt b/ext/strawberry-tagreader/CMakeLists.txt index 65a43a3e..7dc6f405 100644 --- a/ext/strawberry-tagreader/CMakeLists.txt +++ b/ext/strawberry-tagreader/CMakeLists.txt @@ -1,4 +1,5 @@ -include_directories(${PROTOBUF_INCLUDE_DIRS}) +cmake_minimum_required(VERSION 3.0) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_SOURCE_DIR}/ext/libstrawberry-common) @@ -7,29 +8,17 @@ include_directories(${CMAKE_BINARY_DIR}/ext/libstrawberry-tagreader) include_directories(${CMAKE_SOURCE_DIR}/src) include_directories(${CMAKE_BINARY_DIR}/src) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -U__STRICT_ANSI__ -Wall -Wextra -Wpedantic -Woverloaded-virtual -fpermissive") - -if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") -endif() +include_directories(${PROTOBUF_INCLUDE_DIRS}) +include_directories(${TAGLIB_INCLUDE_DIRS}) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) -set(SOURCES - main.cpp - tagreaderworker.cpp -) +set(SOURCES main.cpp tagreaderworker.cpp) qt5_wrap_cpp(MOC ${HEADERS}) qt5_add_resources(QRC data/data.qrc) -add_executable(strawberry-tagreader - ${SOURCES} - ${MOC} - ${QRC} -) +add_executable(strawberry-tagreader ${SOURCES} ${MOC} ${QRC}) target_link_libraries(strawberry-tagreader ${TAGLIB_LIBRARIES} @@ -40,16 +29,11 @@ target_link_libraries(strawberry-tagreader ) if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(strawberry-tagreader - execinfo - ) + target_link_libraries(strawberry-tagreader execinfo) endif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") if(APPLE) - target_link_libraries(strawberry-tagreader - /System/Library/Frameworks/Foundation.framework - ) + target_link_libraries(strawberry-tagreader /System/Library/Frameworks/Foundation.framework) endif(APPLE) - install(TARGETS strawberry-tagreader RUNTIME DESTINATION bin) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index db7fa3c9..a0d683d4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,49 +1,16 @@ -# Strawberry Music Player -# Copyright 2013, Jonas Kvinge -# -# Strawberry is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Strawberry is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Strawberry. If not, see . - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -U__STRICT_ANSI__ -Wall -Wextra -Wpedantic -Woverloaded-virtual -fpermissive") - -if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") -endif() - -option(BUILD_WERROR "Build with -Werror" OFF) - -if(BUILD_WERROR) - if (LINUX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") - endif (LINUX) -endif(BUILD_WERROR) +cmake_minimum_required(VERSION 3.0) if(HAVE_TRANSLATIONS) include(../cmake/Translations.cmake) endif(HAVE_TRANSLATIONS) -# Set up definitions and paths +include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_SOURCE_DIR}/ext/libstrawberry-common) +include_directories(${CMAKE_SOURCE_DIR}/ext/libstrawberry-tagreader) +include_directories(${CMAKE_BINARY_DIR}/ext/libstrawberry-tagreader) -add_definitions(${QT_DEFINITIONS}) -add_definitions(-DQT_USE_QSTRINGBUILDER) -add_definitions(-DQT_NO_URL_CAST_FROM_STRING) -add_definitions(-DBOOST_BIND_NO_PLACEHOLDERS) - -include_directories(${CMAKE_BINARY_DIR}) include_directories(${Boost_INCLUDE_DIRS}) include_directories(${GLIBCONFIG_INCLUDE_DIRS}) include_directories(${GLIB_INCLUDE_DIRS}) @@ -96,10 +63,6 @@ if(HAVE_LIBMTP) include_directories(${LIBMTP_INCLUDE_DIRS}) endif(HAVE_LIBMTP) -include_directories(${CMAKE_SOURCE_DIR}/ext/libstrawberry-common) -include_directories(${CMAKE_SOURCE_DIR}/ext/libstrawberry-tagreader) -include_directories(${CMAKE_BINARY_DIR}/ext/libstrawberry-tagreader) - set(SOURCES core/mainwindow.cpp core/application.cpp @@ -1077,11 +1040,7 @@ if(HAVE_AUDIOCD) endif(HAVE_AUDIOCD) if(HAVE_IMOBILEDEVICE) - target_link_libraries(strawberry_lib - ${LIBIMOBILEDEVICE_LIBRARIES} - ${LIBPLIST_LIBRARIES} - ${LIBUSBMUXD_LIBRARIES} - ) + target_link_libraries(strawberry_lib ${LIBIMOBILEDEVICE_LIBRARIES} ${LIBPLIST_LIBRARIES} ${LIBUSBMUXD_LIBRARIES}) link_directories(${LIBIMOBILEDEVICE_LIBRARY_DIRS}) link_directories(${LIBUSBMUXD_LIBRARY_DIRS}) endif(HAVE_IMOBILEDEVICE) @@ -1109,7 +1068,6 @@ if (APPLE) "-framework ScriptingBridge" ) - target_link_libraries(strawberry_lib ${SPMEDIAKEYTAP_LIBRARIES}) if (HAVE_SPARKLE) include_directories(${SPARKLE}/Headers) target_link_libraries(strawberry_lib ${SPARKLE}) @@ -1132,9 +1090,9 @@ if (UNIX AND NOT APPLE) endif () endif () -if(NOT USE_SYSTEM_SINGLEAPPLICATION) -add_dependencies(strawberry_lib ${SINGLEAPPLICATION_LIBRARIES} ${SINGLECOREAPPLICATION_LIBRARIES}) -endif() +if (NOT USE_SYSTEM_SINGLEAPPLICATION) + add_dependencies(strawberry_lib ${SINGLEAPPLICATION_LIBRARIES} ${SINGLECOREAPPLICATION_LIBRARIES}) +endif () ############################################################################### @@ -1162,9 +1120,7 @@ if(FREEBSD) target_link_libraries(strawberry execinfo) endif() -target_link_libraries(strawberry - strawberry_lib -) +target_link_libraries(strawberry strawberry_lib) # macdeploy.py relies on the blob being built first. add_dependencies(strawberry strawberry-tagreader) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c4f1ad81..ebc60825 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,3 @@ -cmake_minimum_required(VERSION 2.8.11) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fpermissive -Wno-c++11-narrowing -U__STRICT_ANSI__") - find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS Test) find_package(GTest) find_library(GMOCK_LIBRARY gmock) @@ -79,8 +75,7 @@ if(Qt5Test_FOUND AND GTEST_FOUND AND GMOCK_LIBRARY) set_target_properties(${TEST_NAME} PROPERTIES COMPILE_FLAGS "-Wno-bool-conversions") endif (SUPPORTS_NOBOOL) - add_custom_command(TARGET strawberry_test POST_BUILD - COMMAND ./${TEST_NAME}${CMAKE_EXECUTABLE_SUFFIX}) + add_custom_command(TARGET strawberry_test POST_BUILD COMMAND ./${TEST_NAME}${CMAKE_EXECUTABLE_SUFFIX}) add_dependencies(build_tests ${TEST_NAME}) endmacro (add_test_file)