Commit Graph

46 Commits

Author SHA1 Message Date
Martchus 18295c98ec Fix exporting list of required CMake packages 2021-09-11 21:31:17 +02:00
Martchus 6d0148e2c3 Allow overriding BUILD_SHARED_LIBS via a project-specific cache variable 2021-09-11 17:07:43 +02:00
Martchus f55dc67a93 Fix `option(BUILD_SHARED_LIBS …)`
* Fix order of arguments
* Keep building static libraries by default to stick with CMake's default
  except when devel defaults are enabled and we're targeting GNU/Linux
2021-08-21 23:39:17 +02:00
Martchus db87472be9 Unify and improve code for finding OpenSSL
* Unify code for use_openssl and use_crypto
* Make missing OpenSSL targets a fatal error if OpenSSL is required
* Add note that possibly the devel package is missing
    * Under Tumbleweed with missing devel package I've got `OpenSSL_FOUND`
      but no imported targets because the symlink from the devel package
      was missing. This might be due to stale values within the CMake
      cache.
2021-07-07 20:51:57 +02:00
Martchus eace9b44ec Fix linking statically against OpenSSL
`set(… PARENT_SCOPE)` leaves the current scope unaffected so appending the
static dependencies removed the OpenSSL libs themselves again.
2021-07-06 20:02:49 +02:00
Martchus 5291c746df Show warning when OpenSSL can be found but imported targets are not present 2021-07-06 19:48:21 +02:00
Martchus 2d50799cff Set C++ standard within `use_standard_filesystem()` in a generic way
It is important that `cmake_policy(SET CMP0067 NEW)` is set before
`include(CheckCXXSourceCompiles)`.
2021-06-22 16:14:59 +02:00
Martchus e961eb9726 Extend compile test for standard filesystem
Apparently the current compile check is not sufficient:

```
[   54s] -- The C compiler identification is GNU 8.2.1
[   54s] -- The CXX compiler identification is GNU 8.2.1
[   54s] -- Check for working C compiler: /usr/bin/gcc-8
[   54s] -- Check for working C compiler: /usr/bin/gcc-8 - works
[   54s] -- Detecting C compiler ABI info
[   54s] -- Detecting C compiler ABI info - done
[   54s] -- Detecting C compile features
[   54s] -- Detecting C compile features - done
[   54s] -- Check for working CXX compiler: /usr/bin/g++-8
[   55s] -- Check for working CXX compiler: /usr/bin/g++-8 - works
…
[   55s] -- Performing Test COULD_COMPILE_TEST_PROGRAM_0
[   55s] -- Performing Test COULD_COMPILE_TEST_PROGRAM_0 - Success
[   55s] -- Linking tageditor against special library for std::filesystem support is not required.
…
[  109s] FAILED: tageditor
[  109s] : && /usr/bin/g++-8  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -DNDEBUG -O2 -g -DNDEBUG  -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now    -rdynamic CMakeFiles/tageditor.dir/tageditor_autogen/mocs_compilation.cpp.o CMakeFiles/tageditor.dir/application/main.cpp.o CMakeFiles/tageditor.dir/cli/attachmentinfo.cpp.o CMakeFiles/tageditor.dir/cli/fieldmapping.cpp.o CMakeFiles/tageditor.dir/cli/helper.cpp.o CMakeFiles/tageditor.dir/cli/mainfeatures.cpp.o CMakeFiles/tageditor.dir/application/knownfieldmodel.cpp.o CMakeFiles/tageditor.dir/application/targetlevelmodel.cpp.o CMakeFiles/tageditor.dir/application/settings.cpp.o CMakeFiles/tageditor.dir/gui/fileinfomodel.cpp.o CMakeFiles/tageditor.dir/misc/htmlinfo.cpp.o CMakeFiles/tageditor.dir/misc/utility.cpp.o CMakeFiles/tageditor.dir/gui/attachmentsedit.cpp.o CMakeFiles/tageditor.dir/gui/attachmentsmodel.cpp.o CMakeFiles/tageditor.dir/gui/codeedit.cpp.o CMakeFiles/tageditor.dir/gui/entertargetdialog.cpp.o CMakeFiles/tageditor.dir/gui/mainwindow.cpp.o CMakeFiles/tageditor.dir/gui/minimumemptyspinbox.cpp.o CMakeFiles/tageditor.dir/gui/notificationlabel.cpp.o CMakeFiles/tageditor.dir/gui/notificationmodel.cpp.o CMakeFiles/tageditor.dir/gui/pathlineedit.cpp.o CMakeFiles/tageditor.dir/gui/picturepreviewselection.cpp.o CMakeFiles/tageditor.dir/gui/filefilterproxymodel.cpp.o CMakeFiles/tageditor.dir/gui/initiate.cpp.o CMakeFiles/tageditor.dir/gui/javascripthighlighter.cpp.o CMakeFiles/tageditor.dir/gui/renamefilesdialog.cpp.o CMakeFiles/tageditor.dir/gui/settingsdialog.cpp.o CMakeFiles/tageditor.dir/gui/tagedit.cpp.o CMakeFiles/tageditor.dir/gui/tagfieldedit.cpp.o CMakeFiles/tageditor.dir/gui/tageditorwidget.cpp.o CMakeFiles/tageditor.dir/dbquery/dbquery.cpp.o CMakeFiles/tageditor.dir/dbquery/musicbrainz.cpp.o CMakeFiles/tageditor.dir/dbquery/makeitpersonal.cpp.o CMakeFiles/tageditor.dir/dbquery/lyricswikia.cpp.o CMakeFiles/tageditor.dir/gui/dbquerywidget.cpp.o CMakeFiles/tageditor.dir/misc/networkaccessmanager.cpp.o CMakeFiles/tageditor.dir/renamingutility/filesystemitem.cpp.o CMakeFiles/tageditor.dir/renamingutility/filesystemitemmodel.cpp.o CMakeFiles/tageditor.dir/renamingutility/filteredfilesystemitemmodel.cpp.o CMakeFiles/tageditor.dir/renamingutility/renamingengine.cpp.o CMakeFiles/tageditor.dir/renamingutility/tageditorobject.cpp.o CMakeFiles/tageditor.dir/tageditor_autogen/3YJK5W5UP7/qrc_icons.cpp.o CMakeFiles/tageditor.dir/tageditor_autogen/3YJK5W5UP7/qrc_scripts.cpp.o CMakeFiles/tageditor.dir/tageditor_autogen/JU62CA5L7X/qrc_tageditor_translations.cpp.o  -o tageditor  /usr/lib64/libqtutilities.so.6.4.1  /usr/lib64/libtagparser.so.10.0.0  /usr/lib64/libQt5Concurrent.so.5.12.7  /usr/lib64/libQt5WebEngineWidgets.so.5.15.3  /usr/lib64/libc++utilities.so.5.10.4  /usr/lib64/libQt5WebEngineCore.so.5.15.3  /usr/lib64/libQt5WebChannel.so.5.12.7  /usr/lib64/libQt5Positioning.so.5.12.7  /usr/lib64/libQt5Quick.so.5.12.7  /usr/lib64/libQt5Qml.so.5.12.7  /usr/lib64/libQt5Network.so.5.12.7  /usr/lib64/libQt5PrintSupport.so.5.12.7  /usr/lib64/libQt5Widgets.so.5.12.7  /usr/lib64/libQt5Gui.so.5.12.7  /usr/lib64/libQt5Core.so.5.12.7 && :
[  109s] /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/tageditor.dir/cli/mainfeatures.cpp.o: in function `Cli::setTagInfo(Cli::SetTagInfoArgs const&)':
[  109s] /home/abuild/rpmbuild/BUILD/tageditor-3.4.0/build/../cli/mainfeatures.cpp:889: undefined reference to `std::filesystem::last_write_time(std::filesystem::__cxx11::path const&, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >, std::error_code&)'
[  109s] collect2: error: ld returned 1 exit status
```

For `c++utilities` itself it doesn't seem to matter:

```
[   33s] -- Performing Test COULD_COMPILE_TEST_PROGRAM_0
[   35s] -- Performing Test COULD_COMPILE_TEST_PROGRAM_0 - Success
[   35s] -- Linking c++utilities against special library for std::filesystem support is not required.
…
[   43s] [22/22] /usr/bin/cmake -E cmake_symlink_library libc++utilities.so.5.10.4  libc++utilities.so.5 libc++utilities.so && :
[   43s] + RPM_EC=0
```

For some reason the AppImage build doesn't have the problem:

```
[   77s] -- The C compiler identification is GNU 8.2.1
[   77s] -- The CXX compiler identification is GNU 8.2.1
[   77s] -- Check for working C compiler: /usr/bin/gcc-8
[   77s] -- Check for working C compiler: /usr/bin/gcc-8 -- works
[   77s] -- Detecting C compiler ABI info
[   78s] -- Detecting C compiler ABI info - done
[   78s] -- Detecting C compile features
[   78s] -- Detecting C compile features - done
[   78s] -- Check for working CXX compiler: /usr/bin/g++-8
[   78s] -- Check for working CXX compiler: /usr/bin/g++-8 -- works
[   78s] -- Detecting CXX compiler ABI info
[   78s] -- Detecting CXX compiler ABI info - done
[   78s] -- Detecting CXX compile features
[   79s] -- Detecting CXX compile features - done
[   79s] -- Looking for iconv
[   79s] -- Looking for iconv - found
[   79s] -- Using iconv from the standard library for target c++utilities.
[   79s] -- Using std::fstream for NativeFileStream
[   79s] -- Performing Test COULD_COMPILE_TEST_PROGRAM_0
[   80s] -- Performing Test COULD_COMPILE_TEST_PROGRAM_0 - Failed
[   80s] -- Performing Test COULD_COMPILE_TEST_PROGRAM_1
[   81s] -- Performing Test COULD_COMPILE_TEST_PROGRAM_1 - Success
[   81s] -- Linking c++utilities against library "-lstdc++fs" for std::filesystem support.
```
2021-06-17 16:40:05 +02:00
Martchus 9fb3bbe179 Export a target for using only headers of a library
Some backend libraries of Syncthing Tray and Reflective RapidJSON only use
certain headers of qtutilities/c++utilities. The current solution did not
really work because it did not distinguish between the build and install
interface and also did not take compile definitions and options into
account.
2021-01-01 18:42:22 +01:00
Martchus 1c6315a078 Add opt-outs for additional linker flags to achieve a fully statically linked build
See https://github.com/Martchus/syncthingtray/issues/64
2020-04-27 22:55:06 +02:00
Martchus 3fb40baebc Reformat CMake scripts against cmake-format 0.6.3 2019-12-15 18:58:42 +01:00
Martchus 99bc257755 Apply cmake-format 2019-08-06 00:02:38 +02:00
Martchus 81a3d4fa94 Don't skip entire use_pkg_config_module if target exists
Otherwise the same library can not be added to another library
variable.
2019-07-09 18:36:28 +02:00
Martchus 6c9a956a4f Apply cmake-format 2019-06-10 22:43:42 +02:00
Martchus 93bdf5b4f1 Do not error-out if file system lib not found 2019-06-07 16:45:06 +02:00
Martchus d9b4ca5381 Fix build when not file system library required 2019-06-06 15:20:42 +02:00
Martchus aebd324cf4 Add CMake function to use std::filesystem 2019-06-05 23:48:01 +02:00
Martchus bc0d7af67f Apply cmake-format 0.5.1
* Disable autosort as it messes with add_library and
  add_executable calls
2019-06-01 12:14:30 +02:00
Martchus e120a897c5 Add use_package to 3rdParty 2019-05-30 14:04:04 +02:00
Martchus 6489cae19e Apply cmake-format 2019-05-15 15:52:29 +02:00
Martchus e114b24d3c Add helper to use pkg-config modules
This basically creates imported targets from those
pkg-config modules. It also supports static linkage.

The main effort here is that those imported targets
are also exported appropriately. This is implemented
by letting the config script re-run pkg-config as
required.
2019-05-09 19:27:10 +02:00
Martchus a17f322f3c Apply cmake-format 2019-05-04 20:57:56 +02:00
Martchus 1480d9ab63 Support installing multiple configurations within the same prefix 2019-05-04 01:59:45 +02:00
Martchus 8ffe0e6a51 Polish CMake code 2019-04-22 22:19:08 +02:00
Martchus e9cc26478b Don't mix building static and shared libraries 2019-04-22 20:42:48 +02:00
Martchus 86f3bf8b3b Apply cmake-format 2019-02-06 17:30:52 +01:00
Martchus c0f74e4c89 Add BOOST_IOSTREAMS_DYN_LINK to compile defs
if linking dynamically against Boost.Iostreams
2018-10-21 20:24:55 +02:00
Martchus 749eea2ab6 Support NativeFileStream via Boost.Iostreams
So it can also be enabled when not using libstdc++.
2018-09-30 13:55:30 +02:00
Martchus 0dcbb3de55 Improve coding style in CMake modules 2018-02-21 23:07:51 +01:00
Martchus ae249140bc Use also actual lib name to check whether dependency is public
In accordance to 'Fix adding public Qt modules in pkg-config'
in qtutilities (b2e3506ff59ae4b610c91bd9ee96333871fa5864).
2017-10-08 20:24:48 +02:00
Martchus 472e0296d0 Fix adding public static lib dependencies 2017-10-08 19:42:55 +02:00
Martchus 032111eef0 Distinguish exporting/enabling resources of static libs
Required because we now allow to provide dynamic libs as
dependencies of static libs
2017-08-31 02:15:46 +02:00
Martchus b45fe7eaeb Allow providing a shared lib as dependency for a static lib
Previously the case when the dependency of a static library
was provided by a dynamic library has not been handled
correctly leading to linker errors when building the final
application.
2017-08-06 00:35:11 +02:00
Martchus 326551ee02 Allow to force use of external iconv 2017-07-20 01:25:13 +02:00
Martchus 73f11eeb2a detecting 3rdparty libs: Fix overriding cache variables 2017-07-20 01:24:35 +02:00
Martchus 6f146072ea Allow overriding 3rd party libs/includes
So passwordfile can be told to use legacy OpenSSL
header in accordance with Qt 5 which still requires
OpenSSL 1.0
2017-07-04 22:44:32 +02:00
Martchus ecce539a18 Do not set global include dirs
TODO: Set include dirs on target level
2017-05-24 23:29:17 +02:00
Martchus 6042336038 Allow checking whether external lib is used 2017-04-15 23:20:27 +02:00
Martchus 2e0df8aa6a Allow linking only tests in 3rdParty macros
So tagparser tests can link against OpenSSL
for computing checksums
2017-04-08 18:29:21 +02:00
Martchus 64cc931555 Improve CMake modules 2017-02-11 02:30:46 +01:00
Martchus f23c381da4 Support dylib extension used under macOS 2017-01-15 17:44:23 +01:00
Martchus b903adccdb Provide an imported target for libs 2016-11-12 02:06:52 +01:00
Martchus 6e7e87b73f Improve use of 3rd party libs 2016-10-29 00:19:47 +02:00
Martchus fe4e4b2ef5 Fix issues concerning building/using static libraries
- Ensure static versions of 3rd party libs are
  found correctly
- Link tests against statically if only static
  libraries have been built
- Ensure standard lib is linked statically when
  static linkage is enabled
2016-08-19 16:14:55 +02:00
Martchus 323ad615cb Add macro to use iconv 2016-07-27 18:21:43 +02:00
Martchus 189a6fe6ba Approach to enable static linkage
Linking statically might be useful, especially
when linking Windows applications since MinGW
is less buggy then.
2016-07-22 01:35:32 +02:00