Conversion to cmake building system #30

Merged
MicheleC merged 1 commits from feat/cmake-conversion into master 12 months ago

@ -0,0 +1,86 @@
############################################
# #
# Improvements and feedbacks are welcome #
# #
# This file is released under GPL >= 3 #
# #
############################################
cmake_minimum_required( VERSION 3.5 )
#### general package setup
project( gwenview )
#### include essential cmake modules
include( FindPkgConfig )
include( CheckSymbolExists )
include( CheckIncludeFile )
include( CheckLibraryExists )
include( CheckCSourceCompiles )
include( CheckCXXSourceCompiles )
enable_testing()
#### include our cmake modules
include( TDEMacros )
##### set version number ########################
tde_set_project_version( )
##### setup install paths
include( TDESetupPaths )
tde_setup_paths( )
##### optional stuff
option( WITH_ALL_OPTIONS "Enable all optional support" OFF )
option( WITH_KIPI "Enable kipi support" ${WITH_ALL_OPTIONS} )
option( WITH_MNG "Enable mng support" ${WITH_ALL_OPTIONS} )
option( WITH_XCURSOR "Enable xcursor support" ${WITH_ALL_OPTIONS} )
option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} )
##### user requested modules
option( BUILD_ALL "Build all" ON )
option( BUILD_DOC "Build documentation" ${BUILD_ALL} )
##### configure checks
include( ConfigureChecks.cmake )
###### global compiler settings
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" )
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" )
set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" )
##### directories
add_subdirectory( icons )
add_subdirectory( src )
##### other data ################################
tde_conditional_add_project_docs( BUILD_DOC )
##### write configure files
configure_file( config.h.cmake config.h @ONLY )

@ -0,0 +1,134 @@
###########################################
# #
# Improvements and feedback are welcome #
# #
# This file is released under GPL >= 3 #
# #
###########################################
# required stuff
find_package( TQt )
find_package( TDE )
tde_setup_architecture_flags( )
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
tde_setup_largefiles( )
set( ENV{PKG_CONFIG_PATH} "${PKG_CONFIG_PATH}:$ENV{PKG_CONFIG_PATH}:${LIB_INSTALL_DIR}/pkgconfig" )
##### check for gcc visibility support
if( WITH_GCC_VISIBILITY )
tde_setup_gcc_visibility( )
endif( WITH_GCC_VISIBILITY )
##### check for libexiv2
pkg_search_module( EXIV2 exiv2 )
if( NOT EXIV2_FOUND )
tde_message_fatal( "exiv2 is required, but was not found on your system" )
endif( NOT EXIV2_FOUND )
check_include_file_cxx( "exiv2/exiv2.hpp" HAVE_EXIV2_EXIV2_HPP )
##### check for libjpeg
find_package( JPEG )
if( NOT JPEG_FOUND )
tde_message_fatal( "jpeg library is required, but was not found on your system" )
endif()
##### checks for libkipi
MicheleC marked this conversation as resolved
Review

For libkipi we have a file for pkg-config, so instead of searching for a header file we can use pkg-config detection.

For `libkipi` we have a file for pkg-config, so instead of searching for a header file we can use pkg-config detection.
if( WITH_KIPI )
pkg_search_module( LIBKIPI libkipi )
if( NOT LIBKIPI_FOUND )
tde_message_fatal( "libkipi was requested but not found on your system." )
endif( )
set( GV_HAVE_KIPI 1 )
endif( )
##### checks for libmng
if( WITH_MNG )
find_file( HAVE_LIBMNG_H "libmng.h" )
if( NOT HAVE_LIBMNG_H )
tde_message_fatal( "libmng was requested but not found on your system." )
endif( )
set( MNG_LIBRARY mng )
set( HAVE_LIBMNG 1 )
endif( )
##### check for libpng
find_package( PNG )
if( NOT PNG_FOUND )
tde_message_fatal( "png library is required, but was not found on your system" )
endif()
##### check for libxcursor
if( WITH_XCURSOR )
pkg_search_module( XCURSOR xcursor )
if( XCURSOR_FOUND )
set( GV_HAVE_XCURSOR 1 )
else( )
tde_message_fatal( "xcursor library is required, but was not found on your system" )
endif( )
endif()
##### check for lround function
tde_save_and_set( CMAKE_REQUIRED_LIBRARIES "m" )
check_symbol_exists ( lround "math.h" HAVE_LROUND )
tde_restore( CMAKE_REQUIRED_LIBRARIES )
if( NOT HAVE_LROUND )
set( HAVE_LROUND 0 )
endif( NOT HAVE_LROUND )
##### check architecture
if( NOT CMAKE_ARCHITECTURE )
execute_process(
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE CMAKE_ARCHITECTURE
ERROR_VARIABLE CMAKE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE )
set( CMAKE_ARCHITECTURE "${CMAKE_ARCHITECTURE}" CACHE INTERNAL "" FORCE )
message( STATUS "Detected ${CMAKE_ARCHITECTURE} target architecture" )
endif( )
##### check specific architecture dependant support
if( ${CMAKE_ARCHITECTURE} MATCHES "i.86" )
# MMX support
message( STATUS "Performing MMX support test" )
check_c_source_compiles( "
int main() {
#if defined(__GNUC__)
__asm__(\"pxor %mm0, %mm0\");
#else
#error Not gcc on x86/x86_64
#endif
return 0;
}"
HAVE_X86_MMX
)
endif( )

@ -0,0 +1,26 @@
#define VERSION "@VERSION@"
// Defined if you have fvisibility and fvisibility-inlines-hidden support.
#cmakedefine __KDE_HAVE_GCC_VISIBILITY 1
// Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
// significant byte first (like Motorola and SPARC, unlike Intel).
#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
// Defined if you have exiv2/exiv2.hpp header
#cmakedefine HAVE_EXIV2_EXIV2_HPP 1
// Defined if you have libkipi install
#cmakedefine GV_HAVE_KIPI 1
// Defined if you have libmn install
#cmakedefine HAVE_LIBMNG 1
// Defined if you have libxcurso install
#cmakedefine GV_HAVE_XCURSOR 1
// Defined if you have lround function
#cmakedefine HAVE_LROUND 1
// Defined if you have MMX support
#cmakedefine HAVE_X86_MMX 1

@ -0,0 +1,4 @@
add_subdirectory( action )
add_subdirectory( app )
add_subdirectory( cursor )
add_subdirectory( thumbnail )

@ -0,0 +1 @@
tde_install_icons( DESTINATION ${DATA_INSTALL_DIR}/gwenview/icons )

@ -0,0 +1 @@
tde_install_icons( )

@ -0,0 +1,4 @@
install(
MicheleC marked this conversation as resolved
Review

We do not use install written in capital letters.

We do not use `install` written in capital letters.
Review

There are lots of INSTALL in capital letters in TDE cmake files, jsut run rg -g CMake* "INSTALL\(" -l from the tde/main folder.
I have no problem to make it lower case, just pointing out that if we want to make that the standard, we should also update those other files. I can do that too, rather quickly actually, if needed.

There are lots of `INSTALL` in capital letters in TDE cmake files, jsut run `rg -g CMake* "INSTALL\(" -l` from the tde/main folder. I have no problem to make it lower case, just pointing out that if we want to make that the standard, we should also update those other files. I can do that too, rather quickly actually, if needed.
Review

I have renamed to lower letters (will push commit soon). Let me know if the same is preferrable in all the others usages in TDE

I have renamed to lower letters (will push commit soon). Let me know if the same is preferrable in all the others usages in TDE
Review

We certainly prefer it. The question is whether to do this as a separate mass commit or do it gradually with the introduction of the rules for code formatting.

We certainly prefer it. The question is whether to do this as a separate mass commit or do it gradually with the introduction of the rules for code formatting.
Review

I can do a selected mass renaming tomorrow, it won't take long.
Code formatting would be an independent topic.

I can do a selected mass renaming tomorrow, it won't take long. Code formatting would be an independent topic.
FILES zoom.png
DESTINATION ${DATA_INSTALL_DIR}/gwenview/cursors
)

@ -0,0 +1,4 @@
install(
MicheleC marked this conversation as resolved
Review

We do not use install written in capital letters.

We do not use `install` written in capital letters.
FILES wait.png
DESTINATION ${DATA_INSTALL_DIR}/gwenview/thumbnail
)

@ -0,0 +1,24 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${TQT_INCLUDE_DIRS}
${TDE_INCLUDE_DIR}
)
link_directories(
${TQT_LIBRARY_DIRS}
${TDE_LIB_DIR}
)
Fat-Zer marked this conversation as resolved
Review

Do we need all this both here and in all the subdirectories?

Do we need all this both here and in all the subdirectories?
Review

I can test if some/all can be removed. I sort of use a template across the folders to have thinks look more similar. But it is a valid point.

I can test if some/all can be removed. I sort of use a template across the folders to have thinks look more similar. But it is a valid point.
Review

Done

Done
Review

The include_directories() above are also redundant...

The `include_directories()` above are also redundant...
Review

And as for link_directories() I meant it's needed either here or in the subdirectories; at least in one, but not in both.

And as for `link_directories()` I meant it's needed either here or in the subdirectories; at least in one, but not in both.
Review

Re link directories, they are included in one cmake file and I can build gwenview fine (while removing the others, I tested that the build would still succeed).
Re includes, I guess we could do some removal too. In general, we should probably consider this as a TDE wide task, since many cmake conversions have a very similar structure for includes and links.

Re link directories, they are included in one cmake file and I can build gwenview fine (while removing the others, I tested that the build would still succeed). Re includes, I guess we could do some removal too. In general, we should probably consider this as a TDE wide task, since many cmake conversions have a very similar structure for includes and links.
Review

ah I see what you mean. It was for that specific src/CMakeLists.txt file right? yes, they are not required. I will update again.

ah I see what you mean. It was for that specific `src/CMakeLists.txt` file right? yes, they are not required. I will update again.
Review

I have cleaned up includes and link directories, adding the common ones in src/CMakeLists.txt and removing the duplicates from all the other files.

I have cleaned up includes and link directories, adding the common ones in `src/CMakeLists.txt` and removing the duplicates from all the other files.
Review

Looks good.

If I were neat-picking, I'd say that ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} in src/CMakeLists.txt are also redundant ;)

Looks good. If I were neat-picking, I'd say that `${CMAKE_CURRENT_SOURCE_DIR}` and `${CMAKE_CURRENT_BINARY_DIR}` in `src/CMakeLists.txt` are also redundant ;)
Review

If I were neat-picking, I'd say that ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} in src/CMakeLists.txt are also redundant ;)

I would say they are not redundant, but unnecessary in this folder because it does not contain any source or generated headers.

> If I were neat-picking, I'd say that `${CMAKE_CURRENT_SOURCE_DIR}` and `${CMAKE_CURRENT_BINARY_DIR}` in `src/CMakeLists.txt` are also redundant ;) I would say they are not _redundant_, but _unnecessary_ in this folder because it does not contain any source or generated headers.
Review

If I were neat-picking, I'd say that {CMAKE_CURRENT_SOURCE_DIR} and {CMAKE_CURRENT_BINARY_DIR} in src/CMakeLists.txt are also redundant ;)

${CMAKE_CURRENT_BINARY_DIR} is unnecessary (I have removed that), but ${CMAKE_CURRENT_SOURCE_DIR} is required because several files include files as #include "imageutils/imageutils.h", with refers to the src folder (whic is ${CMAKE_CURRENT_SOURCE_DIR}). Alternatively we would have to modify all the includes and make sure we still build fine with autotools too.

> If I were neat-picking, I'd say that ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} in src/CMakeLists.txt are also redundant ;) `${CMAKE_CURRENT_BINARY_DIR}` is unnecessary (I have removed that), but `${CMAKE_CURRENT_SOURCE_DIR}` is required because several files include files as `#include "imageutils/imageutils.h"`, with refers to the `src` folder (whic is `${CMAKE_CURRENT_SOURCE_DIR}`). Alternatively we would have to modify all the includes and make sure we still build fine with autotools too.
##### subfolders
add_subdirectory( app )
add_subdirectory( desktopfiles )
add_subdirectory( gvcore )
add_subdirectory( gvdirpart )
add_subdirectory( gvimagepart )
add_subdirectory( imageutils )
add_subdirectory( tools )
add_subdirectory( tsthread )
add_subdirectory( updates )

@ -0,0 +1,56 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
##### libgwenshared (static)
tde_add_library( gwenshared STATIC_PIC AUTOMOC
SOURCES vtabwidget.cpp
)
##### gwenview (shared)
set( gwenview_SRCS
bookmarkowner.cpp
bookmarkviewcontroller.cpp
bookmarkdialogbase.ui
bookmarkdialog.cpp
configfileoperationspage.ui
configfullscreenpage.ui
configimagelistpage.ui
configimageviewpage.ui
configmiscpage.ui
configslideshowpage.ui
kipiinterface.cpp
mainwindow.cpp
metaedit.cpp
treeview.cpp
dirviewcontroller.cpp
configdialog.cpp
history.cpp
main.cpp
)
tde_add_tdeinit_executable( gwenview AUTOMOC
SOURCES ${gwenview_SRCS}
LINK
gwenshared-static gwenviewcore-shared
tdeutils-shared ${LIBKIPI_LIBRARIES}
DESTINATION ${LIB_INSTALL_DIR}/trinity
)
##### other files
install(
FILES gwenviewui.rc
DESTINATION ${DATA_INSTALL_DIR}/gwenview
)
install(
FILES gwenview.xpm
DESTINATION ${SHARE_INSTALL_PREFIX}/pixmaps
)

@ -0,0 +1,11 @@
##### desktop files
tde_create_translated_desktop(
SOURCE gwenview.desktop
DESTINATION ${XDG_APPS_INSTALL_DIR}
)
tde_create_translated_desktop(
SOURCE konqgwenview.desktop
DESTINATION ${DATA_INSTALL_DIR}/konqueror/servicemenus
)

@ -0,0 +1,90 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
##### gwenviewcore (shared)
set( gwenviewcore_SRCS
pngformattype.cpp
printdialog.cpp
printdialogpagebase.ui
thumbnailloadjob.cpp
imageview.cpp
imageviewcontroller.cpp
document.cpp
externaltoolmanager.cpp
externaltoolcontext.cpp
externaltoolaction.cpp
externaltooldialogbase.ui
externaltooldialog.cpp
fileviewcontroller.cpp
filethumbnailview.cpp
fileoperation.cpp
fileopobject.cpp
filethumbnailviewitem.cpp
filterbar.ui
qxcfi.cpp
archive.cpp
slideshow.cpp
filedetailview.cpp
filedetailviewitem.cpp
imagesavedialog.cpp
jpegformattype.cpp
mngformattype.cpp
xpm.cpp
documentimpl.cpp
documentloadingimpl.cpp
documentloadedimpl.cpp
documentjpegloadedimpl.cpp
documentanimatedloadedimpl.cpp
documentotherloadedimpl.cpp
busylevelmanager.cpp
cache.cpp
threadgate.cpp
imageviewtools.cpp
fullscreenbar.cpp
imageloader.cpp
cursortracker.cpp
captionformatter.cpp
thumbnaildetailsdialogbase.ui
thumbnaildetailsdialog.cpp
xcursor.cpp
mimetypeutils.cpp
bcgdialog.cpp
bcgdialogbase.ui
timeutils.cpp
clicklineedit.cpp
inputdialog.cpp
deletedialog.cpp
deletedialogbase.ui
miscconfig.kcfgc
slideshowconfig.kcfgc
fileoperationconfig.kcfgc
fullscreenconfig.kcfgc
imageviewconfig.kcfgc
fileviewconfig.kcfgc
)
tde_add_library( gwenviewcore SHARED AUTOMOC
SOURCES ${gwenviewcore_SRCS}
LINK
tsthread-static gvimageutils-static
tdecore-shared tdeio-shared tdemediaplayer-shared
tdeparts-shared tdeprint-shared tdeui-shared
${EXIV2_LIBRARIES} ${JPEG_LIBRARIES} ${MNG_LIBRARY}
${PNG_LIBRARIES} ${XCURSOR_LIBRARIES}
MicheleC marked this conversation as resolved
Review

mismatch in indentation

mismatch in indentation
VERSION 1.0.0
DESTINATION ${LIB_INSTALL_DIR}
)
##### other files
install(
FILES
miscconfig.kcfg slideshowconfig.kcfg fileoperationconfig.kcfg
fullscreenconfig.kcfg imageviewconfig.kcfg fileviewconfig.kcfg
DESTINATION ${KCFG_INSTALL_DIR}
)

@ -0,0 +1,31 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
##### gvdirpart (shared)
tde_add_kpart( libgvdirpart AUTOMOC
SOURCES gvdirpart.cpp gvdirpartconfig.kcfgc
LINK tdeparts-shared gwenviewcore-shared
DESTINATION ${LIB_INSTALL_DIR}/trinity
)
##### other files
tde_create_translated_desktop(
SOURCE gvdirpart.desktop
DESTINATION ${SERVICES_INSTALL_DIR}
)
install(
FILES gvdirpart.rc
DESTINATION ${DATA_INSTALL_DIR}/gvdirpart
)
install(
FILES gvdirpartconfig.kcfg
DESTINATION ${KCFG_INSTALL_DIR}
)

@ -0,0 +1,26 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
##### gvimagepart
tde_add_kpart( libgvimagepart AUTOMOC
SOURCES gvimagepart.cpp
LINK tdeparts-shared gwenviewcore-shared
DESTINATION ${LIB_INSTALL_DIR}/trinity
)
##### other files
tde_create_translated_desktop(
SOURCE gvimagepart.desktop
DESTINATION ${SERVICES_INSTALL_DIR}
)
install(
FILES gvimagepart.rc gvimagepartpopup.rc
DESTINATION ${DATA_INSTALL_DIR}/gvimagepart
)

@ -0,0 +1,34 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${EXIV2_INCLUDE_DIRS}
${JPEG_INCLUDE_DIR}
)
##### gvimageutils (static)
set( gvimageutils_SRCS imageutils.cpp jpegcontent.cpp scale.cpp transupp.c croppedqimage.cpp )
if( HAVE_X86_MMX )
list( gvimageutils_SRCS APPEND _SRCS asm_scale.S )
# Force to use C compiler for asm_scale.S instead of ASM
# because it contains mixed code - ASM with C definitions
set_source_files_properties( asm_scale.S PROPERTIES LANGUAGE C )
add_compile_options( -DHAVE_X86_MMX )
endif( )
MicheleC marked this conversation as resolved
Review

It seems that it is possible to combine the processor architecture condition along with the HAVE_X86_MMX condition, because otherwise there is no point in adding the source file to the list. In addition, HAVE_X86_MMX will never be set unless processor architecture is i?86, so the architecture test is unnecessary – the HAVE_X86_MMX condition is sufficient.

It seems that it is possible to combine the processor architecture condition along with the `HAVE_X86_MMX` condition, because otherwise there is no point in adding the source file to the list. In addition, `HAVE_X86_MMX` will never be set unless processor architecture is i?86, so the architecture test is unnecessary – the `HAVE_X86_MMX` condition is sufficient.
tde_add_library( gvimageutils STATIC_PIC AUTOMOC
SOURCES ${gvimageutils_SRCS}
LINK tdecore-shared tdeio-shared ${EXIV2_LIBRARIES} ${JPEG_LIBRARIES}
)
##### testjpegcontent (executable)
tde_add_check_executable( testjpegcontent AUTOMOC
Fat-Zer marked this conversation as resolved
Review

This one seems to be an automated test, if so, you may add TEST, so in get run by make test

This one seems to be an automated test, if so, you may add `TEST`, so in get run by `make test`
Review

Not really, IMO. Inside it has a TDE Application (which implicitly has a GUI and will bring up Dr. Konqui in case of crash) and at the end it prints some errors and a message to the user saying that he will see some error on the console.

It is more a test to be run manually IMO, which is why I didn't add TEST.

Not really, IMO. Inside it has a TDE Application (which implicitly has a GUI and will bring up Dr. Konqui in case of crash) and at the end it prints some errors and a message to the user saying that he will see some error on the console. It is more a test to be run manually IMO, which is why I didn't add `TEST`.
Review

yep... it seems you are right...

yep... it seems you are right...
SOURCES testjpegcontent.cpp
LINK gvimageutils-static
)

@ -17,9 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
// System
#include <math.h>

@ -0,0 +1,6 @@
##### desktop files
tde_create_translated_desktop(
SOURCE gimp.desktop kolourpaint.desktop konqueror.desktop tiledwallpaper.desktop wallpaper.desktop
DESTINATION ${DATA_INSTALL_DIR}/gwenview/tools
)

@ -0,0 +1,11 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
##### tsthread (static)
tde_add_library( tsthread STATIC_PIC AUTOMOC
SOURCES tsthread.cpp tswaitcondition.cpp
)

@ -0,0 +1,11 @@
##### update files
install(
FILES gwenview_thumbnail_size.upd gwenview_1.4_osdformat.upd
DESTINATION ${DATA_INSTALL_DIR}/tdeconf_update
)
install(
PROGRAMS gwenview_thumbnail_size.sh gwenview_1.4_osdformat.sh
DESTINATION ${DATA_INSTALL_DIR}/tdeconf_update
)
Loading…
Cancel
Save