Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CMake: minor improvements

Clean it up a bit and add some more options:
LINGUAS - to select the languages to be installed (default all)
DEBUG_OUTPUT - to enable debug output on terminal (default off)
  • Loading branch information...
commit 05ac7c69dc7ea37d44d18acf5d59ee5774f0b36f 1 parent 4956ccb
@lachs0r authored
Showing with 67 additions and 59 deletions.
  1. +12 −25 CMakeLists.txt
  2. +16 −0 icons/CMakeLists.txt
  3. +39 −34 src/CMakeLists.txt
View
37 CMakeLists.txt
@@ -9,7 +9,7 @@ find_program(QT_LRELEASE_EXECUTABLE NAMES lrelease)
set(SMPLAYER2_VERSION_MAJOR 0)
set(SMPLAYER2_VERSION_MINOR 7)
set(SMPLAYER2_VERSION_RELEASE 0)
-execute_process(COMMAND ${PROJECT_SOURCE_DIR}/version.sh
+execute_process(COMMAND ${PROJECT_SOURCE_DIR}/version.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE SMPLAYER2_VERSION_GITREV OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(SMPLAYER2_VERSION "${SMPLAYER2_VERSION_MAJOR}.${SMPLAYER2_VERSION_MINOR}.${SMPLAYER2_VERSION_RELEASE}${SMPLAYER2_VERSION_GITREV}")
@@ -18,48 +18,35 @@ if (CMAKE_COMPILER_IS_GNUCXX)
add_definitions("-Wall -pedantic -std=c++0x")
endif()
-add_definitions(-DSMPLAYER2_VERSION=\"${SMPLAYER2_VERSION}\")
-add_definitions(-DDATA_PATH=\"${CMAKE_INSTALL_PREFIX}/share/smplayer2\")
+if (MINGW)
+ add_definitions("-U__STRICT_ANSI__")
+endif()
-find_package(Qt COMPONENTS QtNetwork QtXml REQUIRED)
-find_package(ZLIB REQUIRED)
find_package(Quazip)
-set(QT_USE_QTNETWORK TRUE)
-set(QT_USE_QTXML TRUE)
-
if (QUAZIP_FOUND)
option(ENABLE_DOWNLOAD_SUBS "Enable subtitle downloader (requires QuaZip)" ON)
option(QUAZIP_STATIC "Enable this if QuaZip has been built as a static library" OFF)
endif()
-if(ENABLE_DOWNLOAD_SUBS AND QUAZIP_FOUND)
+option(DEBUG_OUTPUT "Enable debug output on terminal" OFF)
+
+if (ENABLE_DOWNLOAD_SUBS AND QUAZIP_FOUND)
set(HAVE_DOWNLOAD_SUBS ON)
if (QUAZIP_STATIC)
add_definitions(-DQUAZIP_STATIC)
endif()
endif()
+if (NOT DEBUG_OUTPUT)
+ add_definitions(-DNO_DEBUG_ON_CONSOLE)
+endif()
+
add_subdirectory(src)
+add_subdirectory(icons)
summary_add("Subtitle downloader" HAVE_DOWNLOAD_SUBS)
summary_show()
-install(FILES icons/smplayer2_icon16.png
- DESTINATION share/icons/hicolor/16x16/apps/
- RENAME application-x-smplayer2.png
-)
-install(FILES icons/smplayer2_icon22.png
- DESTINATION share/icons/hicolor/22x22/apps/
- RENAME application-x-smplayer2.png
-)
-install(FILES icons/smplayer2_icon32.png
- DESTINATION share/icons/hicolor/32x32/apps/
- RENAME application-x-smplayer2.png
-)
-install(FILES icons/smplayer2_icon64.png
- DESTINATION share/icons/hicolor/64x64/apps/
- RENAME application-x-smplayer2.png
-)
install(FILES smplayer2.desktop
DESTINATION share/applications
)
View
16 icons/CMakeLists.txt
@@ -0,0 +1,16 @@
+install(FILES smplayer2_icon16.png
+DESTINATION share/icons/hicolor/16x16/apps/
+RENAME application-x-smplayer2.png
+)
+install(FILES smplayer2_icon22.png
+DESTINATION share/icons/hicolor/22x22/apps/
+RENAME application-x-smplayer2.png
+)
+install(FILES smplayer2_icon32.png
+DESTINATION share/icons/hicolor/32x32/apps/
+RENAME application-x-smplayer2.png
+)
+install(FILES smplayer2_icon64.png
+DESTINATION share/icons/hicolor/64x64/apps/
+RENAME application-x-smplayer2.png
+)
View
73 src/CMakeLists.txt
@@ -1,5 +1,15 @@
-INCLUDE(${QT_USE_FILE})
-ADD_DEFINITIONS(${QT_DEFINITIONS})
+add_definitions(-DSMPLAYER2_VERSION=\"${SMPLAYER2_VERSION}\")
+if(NOT WIN32)
+ add_definitions(-DDATA_PATH=\"${CMAKE_INSTALL_PREFIX}/share/smplayer2\")
+endif()
+
+find_package(Qt COMPONENTS QtNetwork QtXml REQUIRED)
+find_package(ZLIB REQUIRED)
+set(QT_USE_QTNETWORK TRUE)
+set(QT_USE_QTXML TRUE)
+
+include(${QT_USE_FILE})
+add_definitions(${QT_DEFINITIONS})
set(smplayer2_SOURCES
global.cpp
@@ -221,28 +231,6 @@ set(smplayer2_FORMS
videopreview/videopreviewconfigdialog.ui
)
-set(smplayer2_TRANSLATIONS
- translations/smplayer2_ar_SY.ts translations/smplayer2_ku.ts
- translations/smplayer2_bg.ts translations/smplayer2_lt.ts
- translations/smplayer2_ca.ts translations/smplayer2_mk.ts
- translations/smplayer2_cs.ts translations/smplayer2_nl.ts
- translations/smplayer2_da.ts translations/smplayer2_pl.ts
- translations/smplayer2_de.ts translations/smplayer2_pt_BR.ts
- translations/smplayer2_el_GR.ts translations/smplayer2_pt.ts
- translations/smplayer2_en_US.ts translations/smplayer2_ro_RO.ts
- translations/smplayer2_es.ts translations/smplayer2_ru_RU.ts
- translations/smplayer2_et.ts translations/smplayer2_sk.ts
- translations/smplayer2_eu.ts translations/smplayer2_sl_SI.ts
- translations/smplayer2_fi.ts translations/smplayer2_sr.ts
- translations/smplayer2_fr.ts translations/smplayer2_sv.ts
- translations/smplayer2_gl.ts translations/smplayer2_tr.ts
- translations/smplayer2_hu.ts translations/smplayer2_uk_UA.ts
- translations/smplayer2_it.ts translations/smplayer2_vi_VN.ts
- translations/smplayer2_ja.ts translations/smplayer2_zh_CN.ts
- translations/smplayer2_ka.ts translations/smplayer2_zh_TW.ts
- translations/smplayer2_ko.ts
-)
-
set(smplayer2_RESOURCES icons.qrc)
set(smplayer2_LIBS ${QT_LIBRARIES} ${ZLIB_LIBRARY})
@@ -266,7 +254,6 @@ if(WIN32)
add_definitions(-DSCREENSAVER_OFF)
add_definitions(-DUSE_ASSOCIATIONS)
- add_definitions(-DNO_DEBUG_ON_CONSOLE)
set(smplayer2_SOURCES ${smplayer2_SOURCES}
screensaver.cpp
prefassociations.cpp
@@ -282,20 +269,38 @@ if(WIN32)
)
endif()
-QT4_WRAP_CPP(smplayer2_HEADERS_MOC ${smplayer2_HEADERS})
-QT4_WRAP_UI(smplayer2_FORMS_HEADERS ${smplayer2_FORMS})
-QT4_ADD_TRANSLATION(smplayer2_TRANSLATIONS_QM ${smplayer2_TRANSLATIONS})
-QT4_ADD_RESOURCES(smplayer2_RESOURCES_RCC ${smplayer2_RESOURCES})
+set(LINGUAS "All" CACHE STRING "\"All\", a space-seperated list of translations to install with SMPlayer2, or \"None\".")
+if (LINGUAS STREQUAL "All")
+ file(GLOB smplayer2_LANGUAGES translations/*.ts)
+else ()
+if (NOT LINGUAS OR LINGUAS STREQUAL "None")
+ set (smplayer2_LANGUAGES "")
+else ()
+ string(REGEX MATCHALL [a-zA-Z_]+
+ langs ${LINGUAS})
+ foreach(lang ${langs})
+ list(APPEND langs translations/smplayer2_${lang}.ts)
+ endforeach()
+ file(GLOB smplayer2_LANGUAGES ${langs})
+endif ()
+endif ()
+
+qt4_wrap_cpp(smplayer2_HEADERS_MOC ${smplayer2_HEADERS})
+qt4_wrap_ui(smplayer2_FORMS_HEADERS ${smplayer2_FORMS})
+qt4_add_translation(smplayer2_TRANSLATIONS ${smplayer2_LANGUAGES})
+qt4_add_resources(smplayer2_RESOURCES_RCC ${smplayer2_RESOURCES})
+add_custom_target(translations DEPENDS ${smplayer2_TRANSLATIONS})
-ADD_EXECUTABLE(smplayer2
+add_executable(smplayer2
${smplayer2_SOURCES}
${smplayer2_HEADERS_MOC}
${smplayer2_FORMS_HEADERS}
- ${smplayer2_TRANSLATIONS_QM}
${smplayer2_RESOURCES_RCC}
)
-TARGET_LINK_LIBRARIES(smplayer2 ${smplayer2_LIBS})
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
+
+add_dependencies(smplayer2 translations)
+target_link_libraries(smplayer2 ${smplayer2_LIBS})
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
install(TARGETS smplayer2 RUNTIME DESTINATION bin)
-install(FILES ${smplayer2_TRANSLATIONS_QM} DESTINATION share/smplayer2/translations)
+install(FILES ${smplayer2_TRANSLATIONS} DESTINATION share/smplayer2/translations)
Please sign in to comment.
Something went wrong with that request. Please try again.