From 74b4e2ec167a566bc314177e7ad167cb2d91b5a9 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Fri, 4 Sep 2015 13:02:46 +0200 Subject: [PATCH 1/7] Fix build of Logger.cpp with an unpatched version of gcc on Windows. --- src/libtomahawk/utils/Logger.cpp | 2 +- src/tomahawk/CMakeLists.win32.cmake | 14 ++++++++++++-- src/tomahawk/Config.h.in | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libtomahawk/utils/Logger.cpp b/src/libtomahawk/utils/Logger.cpp index 80b01236f..98c8b1c40 100644 --- a/src/libtomahawk/utils/Logger.cpp +++ b/src/libtomahawk/utils/Logger.cpp @@ -188,7 +188,7 @@ setupLogfile( QFile& f ) } } -#ifdef _WIN32 +#ifdef OFSTREAM_CAN_OPEN_WCHAR_FILE_NAMES // this is not supported in upstream libstdc++ as shipped with GCC // GCC needs the patch from https://gcc.gnu.org/ml/libstdc++/2011-06/msg00066.html applied // we could create a CMake check like the one for taglib, but I don't care right now :P diff --git a/src/tomahawk/CMakeLists.win32.cmake b/src/tomahawk/CMakeLists.win32.cmake index b7a2e2a78..3e5b96483 100644 --- a/src/tomahawk/CMakeLists.win32.cmake +++ b/src/tomahawk/CMakeLists.win32.cmake @@ -1,5 +1,5 @@ -ADD_DEFINITIONS( /DNOMINMAX ) -ADD_DEFINITIONS( /DWIN32_LEAN_AND_MEAN ) +ADD_DEFINITIONS( -DNOMINMAX ) +ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN ) ADD_DEFINITIONS( -static-libgcc ) ADD_DEFINITIONS( -DUNICODE ) @@ -21,3 +21,13 @@ SET( OS_SPECIFIC_LINK_LIBRARIES if(QTSPARKLE_FOUND) list(APPEND OS_SPECIFIC_LINK_LIBRARIES ${QTSPARKLE_LIBRARIES}) endif() + + +include(CheckCXXSourceCompiles) + +check_cxx_source_compiles( "#include + int main(){ + ofstream stream(L\"Test\"); + return 0; + }" + OFSTREAM_CAN_OPEN_WCHAR_FILE_NAMES) \ No newline at end of file diff --git a/src/tomahawk/Config.h.in b/src/tomahawk/Config.h.in index 467354fdb..f3c180713 100644 --- a/src/tomahawk/Config.h.in +++ b/src/tomahawk/Config.h.in @@ -27,4 +27,6 @@ #cmakedefine HAVE_VLC_ALBUMARTIST #cmakedefine HAVE_X11 +#cmakedefine OFSTREAM_CAN_OPEN_WCHAR_FILE_NAMES + #endif // CONFIG_H_IN From 7caee33dcc959ce5a891c544d8bc8f25864f2234 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Fri, 4 Sep 2015 13:46:52 +0200 Subject: [PATCH 2/7] ofstream is in std:: --- src/tomahawk/CMakeLists.win32.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tomahawk/CMakeLists.win32.cmake b/src/tomahawk/CMakeLists.win32.cmake index 3e5b96483..cd883d2df 100644 --- a/src/tomahawk/CMakeLists.win32.cmake +++ b/src/tomahawk/CMakeLists.win32.cmake @@ -27,7 +27,7 @@ include(CheckCXXSourceCompiles) check_cxx_source_compiles( "#include int main(){ - ofstream stream(L\"Test\"); + std::ofstream stream(L\"Test\"); return 0; }" OFSTREAM_CAN_OPEN_WCHAR_FILE_NAMES) \ No newline at end of file From 16b4cb93d88161b2397cda53a70555d5eff16420 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Fri, 4 Sep 2015 14:55:37 +0200 Subject: [PATCH 3/7] Cleanup config setup to make sure defines are set before config.h is generated. --- .../CMakeLists.linux.cmake | 0 src/{tomahawk => libtomahawk}/CMakeLists.osx.cmake | 0 src/libtomahawk/CMakeLists.txt | 11 +++++++++-- src/{tomahawk => libtomahawk}/CMakeLists.unix.cmake | 0 .../CMakeLists.win32.cmake | 0 src/{tomahawk => libtomahawk}/Config.h.in | 0 src/{tomahawk => libtomahawk}/TomahawkVersion.h.in | 0 src/tomahawk/CMakeLists.txt | 13 ------------- 8 files changed, 9 insertions(+), 15 deletions(-) rename src/{tomahawk => libtomahawk}/CMakeLists.linux.cmake (100%) rename src/{tomahawk => libtomahawk}/CMakeLists.osx.cmake (100%) rename src/{tomahawk => libtomahawk}/CMakeLists.unix.cmake (100%) rename src/{tomahawk => libtomahawk}/CMakeLists.win32.cmake (100%) rename src/{tomahawk => libtomahawk}/Config.h.in (100%) rename src/{tomahawk => libtomahawk}/TomahawkVersion.h.in (100%) diff --git a/src/tomahawk/CMakeLists.linux.cmake b/src/libtomahawk/CMakeLists.linux.cmake similarity index 100% rename from src/tomahawk/CMakeLists.linux.cmake rename to src/libtomahawk/CMakeLists.linux.cmake diff --git a/src/tomahawk/CMakeLists.osx.cmake b/src/libtomahawk/CMakeLists.osx.cmake similarity index 100% rename from src/tomahawk/CMakeLists.osx.cmake rename to src/libtomahawk/CMakeLists.osx.cmake diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 7f6300067..8addd4c59 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -6,9 +6,16 @@ add_definitions( -DDLLEXPORT_PRO ) add_definitions( -DQT_SHAREDPOINTER_TRACK_POINTERS ) add_definitions( -DPORTFWDDLLEXPORT_STATIC ) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../tomahawk/Config.h.in +IF( WIN32 ) + INCLUDE( "CMakeLists.win32.cmake" ) +ENDIF( WIN32 ) +IF( UNIX ) + INCLUDE( "CMakeLists.unix.cmake" ) +ENDIF( UNIX ) + +configure_file(Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../tomahawk/TomahawkVersion.h.in +configure_file(TomahawkVersion.h.in ${CMAKE_CURRENT_BINARY_DIR}/TomahawkVersion.h) set( libGuiSources diff --git a/src/tomahawk/CMakeLists.unix.cmake b/src/libtomahawk/CMakeLists.unix.cmake similarity index 100% rename from src/tomahawk/CMakeLists.unix.cmake rename to src/libtomahawk/CMakeLists.unix.cmake diff --git a/src/tomahawk/CMakeLists.win32.cmake b/src/libtomahawk/CMakeLists.win32.cmake similarity index 100% rename from src/tomahawk/CMakeLists.win32.cmake rename to src/libtomahawk/CMakeLists.win32.cmake diff --git a/src/tomahawk/Config.h.in b/src/libtomahawk/Config.h.in similarity index 100% rename from src/tomahawk/Config.h.in rename to src/libtomahawk/Config.h.in diff --git a/src/tomahawk/TomahawkVersion.h.in b/src/libtomahawk/TomahawkVersion.h.in similarity index 100% rename from src/tomahawk/TomahawkVersion.h.in rename to src/libtomahawk/TomahawkVersion.h.in diff --git a/src/tomahawk/CMakeLists.txt b/src/tomahawk/CMakeLists.txt index 027af3371..9cc2255d8 100644 --- a/src/tomahawk/CMakeLists.txt +++ b/src/tomahawk/CMakeLists.txt @@ -109,13 +109,6 @@ INCLUDE_DIRECTORIES( SET( OS_SPECIFIC_LINK_LIBRARIES "" ) -IF( WIN32 ) - INCLUDE( "CMakeLists.win32.cmake" ) -ENDIF( WIN32 ) -IF( UNIX ) - INCLUDE( "CMakeLists.unix.cmake" ) -ENDIF( UNIX ) - IF( APPLE ) SET( CMAKE_LINKER_FLAGS "-headerpad_max_install_names ${CMAKE_LINKER_FLAGS}" ) @@ -130,12 +123,6 @@ ENDIF( QCA2_FOUND ) INCLUDE(GNUInstallDirs) -# currently only in libtomahawk, we might want to properly split what's in which config file -# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.h.in -# ${CMAKE_CURRENT_BINARY_DIR}/config.h) -# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TomahawkVersion.h.in -# ${CMAKE_CURRENT_BINARY_DIR}/TomahawkVersion.h) - # translations include( ${CMAKE_SOURCE_DIR}/lang/translations.cmake ) add_tomahawk_translations( ${TOMAHAWK_TRANSLATION_LANGUAGES} ) From c8c1affca2f6adfd4bb48c8bbb5c6262690e1f5a Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Fri, 4 Sep 2015 14:57:36 +0200 Subject: [PATCH 4/7] Only try to build with QtSparkle if it has been found. --- src/libtomahawk/Config.h.in | 2 +- src/tomahawk/TomahawkWindow.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libtomahawk/Config.h.in b/src/libtomahawk/Config.h.in index f3c180713..abe825b3f 100644 --- a/src/libtomahawk/Config.h.in +++ b/src/libtomahawk/Config.h.in @@ -15,12 +15,12 @@ #cmakedefine WITH_CRASHREPORTER #cmakedefine WITH_BINARY_ATTICA -#cmakedefine WITH_QtSparkle #cmakedefine WITH_UPOWER #cmakedefine WITH_GNOMESHORTCUTHANDLER #cmakedefine LIBLASTFM_FOUND #cmakedefine QCA2_FOUND +#cmakedefine QtSparkle_FOUND #cmakedefine TOMAHAWK_FINEGRAINED_MESSAGES #cmakedefine COMPLEX_TAGLIB_FILENAME diff --git a/src/tomahawk/TomahawkWindow.cpp b/src/tomahawk/TomahawkWindow.cpp index 630319ceb..7513dee49 100644 --- a/src/tomahawk/TomahawkWindow.cpp +++ b/src/tomahawk/TomahawkWindow.cpp @@ -88,7 +88,7 @@ #include "config.h" #if defined( Q_OS_WIN ) - #if defined ( WITH_QtSparkle ) + #if defined ( QtSparkle_FOUND ) #if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) #include #else @@ -521,7 +521,7 @@ TomahawkWindow::setupUpdateCheck() #if defined( Q_OS_MAC ) && defined( HAVE_SPARKLE ) connect( ActionCollection::instance()->getAction( "checkForUpdates" ), SIGNAL( triggered( bool ) ), SLOT( checkForUpdates() ) ); - #elif defined( Q_OS_WIN ) && defined( WITH_QtSparkle ) + #elif defined( Q_OS_WIN ) && defined( QtSparkle_FOUND ) QUrl updaterUrl; if ( qApp->arguments().contains( "--debug" ) ) From e13f996382cffee3d65e308ea134d206bf755191 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Fri, 4 Sep 2015 15:28:58 +0200 Subject: [PATCH 5/7] FOO_FOUND is uppercase. --- src/libtomahawk/Config.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libtomahawk/Config.h.in b/src/libtomahawk/Config.h.in index abe825b3f..e662103e8 100644 --- a/src/libtomahawk/Config.h.in +++ b/src/libtomahawk/Config.h.in @@ -20,7 +20,7 @@ #cmakedefine LIBLASTFM_FOUND #cmakedefine QCA2_FOUND -#cmakedefine QtSparkle_FOUND +#cmakedefine QTSPARKLE_FOUND #cmakedefine TOMAHAWK_FINEGRAINED_MESSAGES #cmakedefine COMPLEX_TAGLIB_FILENAME From d54fc628f75678c4f1c4d6a51e1a441d269c682e Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Fri, 4 Sep 2015 15:30:04 +0200 Subject: [PATCH 6/7] Fix case for QTSPARKLE_FOUND define. --- src/tomahawk/TomahawkWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tomahawk/TomahawkWindow.cpp b/src/tomahawk/TomahawkWindow.cpp index 7513dee49..b382eaa38 100644 --- a/src/tomahawk/TomahawkWindow.cpp +++ b/src/tomahawk/TomahawkWindow.cpp @@ -88,7 +88,7 @@ #include "config.h" #if defined( Q_OS_WIN ) - #if defined ( QtSparkle_FOUND ) + #if defined ( QTSPARKLE_FOUND ) #if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) #include #else @@ -521,7 +521,7 @@ TomahawkWindow::setupUpdateCheck() #if defined( Q_OS_MAC ) && defined( HAVE_SPARKLE ) connect( ActionCollection::instance()->getAction( "checkForUpdates" ), SIGNAL( triggered( bool ) ), SLOT( checkForUpdates() ) ); - #elif defined( Q_OS_WIN ) && defined( QtSparkle_FOUND ) + #elif defined( Q_OS_WIN ) && defined( QTSPARKLE_FOUND ) QUrl updaterUrl; if ( qApp->arguments().contains( "--debug" ) ) From dab59cb20576fe3aaf9dfdbd71e362ef407e865d Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Fri, 4 Sep 2015 15:32:28 +0200 Subject: [PATCH 7/7] Remove comment about implementing a test for wchar_t suport in ofstream --- src/libtomahawk/utils/Logger.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libtomahawk/utils/Logger.cpp b/src/libtomahawk/utils/Logger.cpp index 98c8b1c40..d57646127 100644 --- a/src/libtomahawk/utils/Logger.cpp +++ b/src/libtomahawk/utils/Logger.cpp @@ -191,7 +191,6 @@ setupLogfile( QFile& f ) #ifdef OFSTREAM_CAN_OPEN_WCHAR_FILE_NAMES // this is not supported in upstream libstdc++ as shipped with GCC // GCC needs the patch from https://gcc.gnu.org/ml/libstdc++/2011-06/msg00066.html applied - // we could create a CMake check like the one for taglib, but I don't care right now :P logStream.open( f.fileName().toStdWString().c_str() ); #else logStream.open( f.fileName().toStdString().c_str() );