ruben2020 / codequery

A code-understanding, code-browsing or code-search tool. This is a tool to index, then query or search C, C++, Java, Python, Ruby, Go and Javascript source code. It builds upon the databases of cscope and ctags, and provides a nice GUI tool.
https://ruben2020.github.io/codequery/
Mozilla Public License 2.0
680 stars 86 forks source link

gui/CMakeLists.txt: Wrong condition for BUILD_QT6 #99

Closed nunotexbsd closed 3 months ago

nunotexbsd commented 3 months ago

Hello,

I'm working on updating codequery FreeBSD port to 1.0.0 It builds fine with Qt6 but I've noticed that gui/CMakeLists.txt have some issues:

[ 96% 132/133] /usr/bin/c++ ... -DUSE_QT5 ...

gui/CMakeLists.txt:

else (BUILD_QT5)

  find_package(Qt6 REQUIRED COMPONENTS Core Widgets Concurrent Xml LinguistTools )
  set(CMAKE_AUTOMOC ON)
  set(CMAKE_AUTORCC OFF)
  set(CMAKE_AUTOUIC OFF)

  add_definitions( -DUSE_QT5 )
  add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00)

  set_target_properties(Qt6::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")

  get_target_property(QT_RCC_EXECUTABLE Qt6::rcc LOCATION)

  qt6_add_translation( QM ${CODEQUERY_TRANS} )
<snip>

Should it have a BUILD_QT6 condition and build with -DUSE_QT6?

ldd:

=>> Checking shared library dependencies
 0x0000000000000001 NEEDED               Shared library: [libGLX.so.0]
 0x0000000000000001 NEEDED               Shared library: [libOpenGL.so.0]
 0x0000000000000001 NEEDED               Shared library: [libQt6Concurrent.so.6]
 0x0000000000000001 NEEDED               Shared library: [libQt6Core.so.6]
 0x0000000000000001 NEEDED               Shared library: [libQt6Core5Compat.so.6]
 0x0000000000000001 NEEDED               Shared library: [libQt6Gui.so.6]
 0x0000000000000001 NEEDED               Shared library: [libQt6Widgets.so.6]
 0x0000000000000001 NEEDED               Shared library: [libQt6Xml.so.6]
 0x0000000000000001 NEEDED               Shared library: [libc++.so.1]
 0x0000000000000001 NEEDED               Shared library: [libc.so.7]
 0x0000000000000001 NEEDED               Shared library: [libcxxrt.so.1]
 0x0000000000000001 NEEDED               Shared library: [libgcc_s.so.1]
 0x0000000000000001 NEEDED               Shared library: [libm.so.5]
 0x0000000000000001 NEEDED               Shared library: [libsqlite3.so.0]
 0x0000000000000001 NEEDED               Shared library: [libthr.so.3]

Thanks

ruben2020 commented 3 months ago

Is that a warning or error? Qt itself doesn't use USE_QT5. I was using it to select between Qt5-only and Qt4-only API. Although now Qt4-only API should have been all removed. I'll check it out.

nunotexbsd commented 3 months ago

Hello,

As I said it builds fine with Qt6 but build log shows -DUSE_QT5 and it comes from:

https://github.com/ruben2020/codequery/blob/b2a6b11f753c1e9fb14abc7a37ac1fc7add5be28/gui/CMakeLists.txt#L126 https://github.com/ruben2020/codequery/blob/b2a6b11f753c1e9fb14abc7a37ac1fc7add5be28/gui/CMakeLists.txt#L136 and again: https://github.com/ruben2020/codequery/blob/b2a6b11f753c1e9fb14abc7a37ac1fc7add5be28/gui/CMakeLists.txt#L192 https://github.com/ruben2020/codequery/blob/b2a6b11f753c1e9fb14abc7a37ac1fc7add5be28/gui/CMakeLists.txt#L199

if condition refers BUILD_QT5 twice with no reference to BUILD_QT6.

ruben2020 commented 3 months ago

@nunotexbsd I just checked. USE_QT5 is used in small_lib.h. It is needed there also for Qt6. So everything is correct. Next time I will remove that definition and replace it with standard Qt macros if available. Or otherwise, with a generic USE_QT definition. Can you release this version for FreeBSD or do you still have any problem?

ruben2020 commented 3 months ago

The CMakeLists syntax is awkward but it's correct. ELSE(BUILD_QT5) means if not BUILD_QT5. See manual:

Per legacy, the else() and endif() commands admit an optional argument. If used, it must be a verbatim repeat of the argument of the opening if command.

nunotexbsd commented 3 months ago

@ruben2020

Thanks very much for explanation! Sorry for the noise, always learning :)

Cheers