Commit Graph

371 Commits

Author SHA1 Message Date
Martchus 7fb2a9ed73 Avoid duplicating the `lib` prefix in the pkg-config file
This is in accordance with omitting the `lib` prefix of the target if the
project name already starts with `lib`.
2021-01-08 00:39:08 +01:00
Martchus 0be639ea97 Use `-lfoo` form in pkg-config file if dependency doesn't look like a path
So e.g. `-lpthread` is added to the pkg-config file instead of just
`pthread`.
2021-01-08 00:37:14 +01:00
Martchus b1b0c10366 Prevent reading library properties from interface library targets 2021-01-07 20:06:12 +01: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 27c8a17f99 Allow enforcing absence of a target suffix for Syncthing Tray's test helper 2021-01-01 18:38:09 +01:00
Martchus 47f7252bc0 Remove leftover message from debugging 2021-01-01 18:35:49 +01:00
Martchus 7ad2a9818d Support target suffix when generating the dependency list for the config header 2021-01-01 18:34:43 +01:00
Martchus a5d2aa15e0 Support Qt 6 modules when generating the dependency list for the config header 2021-01-01 18:32:27 +01:00
Martchus 8a9d72bee9 Disable linking against default Qt plugins
This change would obviously better go into qtutilities. However, it is
easier done here and doesn't pull in any dependency on Qt anyways.
2020-12-20 17:53:37 +01:00
Martchus 80d2823915 Add PROJECT_CONFIG_SUFFIX to the config header 2020-12-14 20:57:05 +01:00
Martchus 6905b1a216 Apply cmake-format 2020-11-25 18:02:24 +01:00
Martchus a40ee3aa7e Use query_qmake_variable_path if available 2020-11-11 18:51:50 +01:00
Martchus e5989dd4d1 Allow setting a display name for the configuration
This also allow to clear the display name because it isn't always nice to
incorporate it within the application name (e.g. static Windows builds).
2020-11-02 23:26:37 +01:00
Martchus 3a8ae77477 Improve handling configuration suffix
* Use configuration suffix when installing icons
* Include configuration name suffix in application name

This way differently configured versions of the same applications should be
co-installable within the same prefix. That is useful to install the Qt 6
version of an application alongside the Qt 5 version.
2020-10-23 16:58:41 +02:00
Martchus e2f170ddd5 Fix install-mingw-w64-strip (and underlying targets)
* Fix escaping issues with Ninja
* Use `$<TARGET_LINKER_FILE_NAME:tgt>` to avoid hard-coding
  library extensions
2020-10-10 16:45:58 +02:00
Martchus 98e6f360af Apply cmake-format 2020-10-10 01:07:06 +02:00
Martchus 0b267c7959 Avoid duplicating the "lib" prefix
if the target name already starts with "lib"
2020-09-23 22:48:28 +02:00
Martchus 26b6ef0486 Avoid 'not a git repository (or any of the parent directories)' during configuration
Try to append the Git revision only if the source directory is actually a
Git checkout.
2020-09-12 22:24:45 +02:00
Martchus 60d9a80b6a Improve icon generation
* Remove PNG_ICON_CROP
    * Not sure how that was supposed to be useful because even for projects
      without PNG_ICON_NO_CROP it does not make much sense
* Test multiple sizes to determine the PNG path automatically
* Locate PNG in basic config so the path is also automatically determined
  for the macOS bundle as well
* Log status message when ffmpeg/png2icns are not available
* Format CMake code more nicely
2020-08-11 23:12:17 +02:00
Martchus 7dab98b257 Use a higher resolution for Windows icons for better High-DPI support 2020-08-05 18:21:52 +02:00
Martchus 84011c2768 Apply CMake format 2020-07-07 12:14:05 +02:00
Martchus d0076e24a7 Get rid of WINDOWS_EXT completely as it is now no longer used 2020-07-04 15:21:55 +02:00
Martchus 534aaf0b4d Fix 'OriginalFilename' in Windows RC file
Rely on generator expressions to get the correct filename. This has never
worked because WINDOWS_EXT was usually only set after WindowsResources has
been included.
2020-07-04 15:21:20 +02:00
Martchus 47850ace49 Remove leftovers from _run target
See c66420b1dc
2020-07-04 15:14:14 +02:00
Martchus b03332f37a Add "SOVERSION" as suffix to shared libraries for mingw-w64 targets
* Also enable the "lib" prefix which CMake would add by default again; it
  has only been removed to preserve compatibility with qmake when switching
  from qmake to CMake
* None of these changes are enabled by default to preserve compatibility
2020-07-04 14:43:26 +02:00
Martchus 63b5fb9c14 Add PROJECT_VARNAME and PROJECT_VARNAME_UPPER to config header 2020-06-23 02:06:29 +02:00
Martchus 942044ea30 Make cache variable doc string compatible with Qt Creator
The double quotes need to be removed from the doc string. Otherwise, Qt
Creator creates a line like
```
set("EXCLUDE_TESTS_FROM_ALL" "OFF" CACHE "BOOL" "specifies whether to exclude tests from the "all" target (enabled by default)" FORCE)
```
in its `qtcsettings.cmake` which doesn't work because the escaping is
missing.
2020-06-22 22:29:21 +02:00
Martchus f24f09f79a Fix setting test properties for coverage when special target name configured 2020-06-22 22:26:17 +02:00
Martchus 74b010cbb9 Make manually added test targets as part of the check target 2020-06-16 01:09:39 +02:00
Martchus a9453483a7 Allow adding test targets manually 2020-06-15 22:28:19 +02:00
Martchus fe5dc5e6a7 Apply cmake-format 0.6.10 2020-04-27 22:59:06 +02: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 6273b42643 Fix remaining hard-coded install dirs
See https://github.com/Martchus/cpp-utilities/issues/17#issuecomment-596420331
2020-03-09 10:45:20 +01:00
Martchus e241d718ce Apply cmake-format 2020-03-05 19:05:33 +01:00
Martchus e94d42f19c Support passing absolute path to CMAKE_INSTALL_BINDIR/LIBDIR
Same as b2a2773 but for CMAKE_INSTALL_BINDIR and CMAKE_INSTALL_LIBDIR.
2020-03-05 14:52:52 +01:00
Martchus 0733f0705d Check one more parent level for LICENSE file
Hack to fix license auto-detection for Plasmoid
2020-02-14 22:30:10 +01:00
Martchus 2b3adc3a6f Don't prefix CMAKE_INSTALL_DATAROOTDIR; it might be absolute
Same as https://github.com/Martchus/cpp-utilities/issues/18 but for
the share directory.
2020-02-14 22:29:07 +01:00
Martchus e9803a41dc Fix inconsistent variables for compile options/definitions
So these options/definitions should no longer be missing in some
places, e.g. the pkg-config file.
2020-02-14 13:22:47 +01:00
Martchus 4dd2179f19 Fix remaining install dirs to use GNUInstallDirs consistently 2020-02-13 11:32:28 +01:00
Martchus b2a2773cdf Support passing absolute path to CMAKE_INSTALL_INCLUDEDIR
See https://github.com/Martchus/cpp-utilities/issues/18
2020-02-13 11:19:36 +01:00
Martchus 1eb64f1208 Make install directory for bash completion files customizable
* Use CMAKE_INSTALL_DATAROOTDIR for default
* Allow overriding via BASH_COMPLETION_INSTALL_DIR
2020-02-10 17:22:17 +01:00
Martchus 115133b7a5 Use target name for bash completion file
Otherwise it doesn't seem to be sourced automatically
2020-02-10 17:15:32 +01:00
Martchus 30878fab07 Prevent duplicated LIB_SUFFIX
Some build system macros might pass CMAKE_INSTALL_LIBDIR/LIB_INSTALL_DIR
and LIB_SUFFIX at the same time. I suppose in this case the LIB_SUFFIX
should not be added if it is already present to avoid `lib6464`.
2020-02-04 17:09:47 +01:00
Martchus fe43824c98 Allow passing LIB_INSTALL_DIR as well
That variable (but not `CMAKE_INSTALL_LIBDIR`) is apparently
passed when building for Fedora with the `%cmake` RPM macro.
2020-02-04 15:30:01 +01:00
Martchus dcb1d896c2 Apply cmake-format 2020-02-04 15:24:13 +01:00
Martchus c97dfbfd4c Use GNUInstallDirs
See https://github.com/Martchus/cpp-utilities/issues/17
2020-02-01 00:01:26 +01:00
Martchus f5e275288d Reformat CMake files with cmake-format 0.6.7 2020-01-26 19:24:04 +01:00
Martchus 0b56ecfb04 Run cmake-format individually for each file
Seems like cmake-format 0.6.7 only applies CLI options
to the first file anymore. So in order to have the options
applied to all files and not just the first one just
invoke it for each file individually.
2020-01-26 19:23:18 +01:00
Martchus 522d2e8cc8 Avoid an indentation level in TestTarget.cmake 2020-01-20 17:57:03 +01:00
Martchus d5930c8d60 Set visbility preset for test application to default 2020-01-20 17:54:28 +01:00
Martchus a9cb91bee2 Set default visibility explicitely to hidden
Hidden default visibility is already expected to be handled by
users of the library because it is the default under Windows.
2020-01-10 18:05:55 +01:00
Martchus 9d8135bfd7 Require CMake 3.3.0 in all modules 2020-01-10 18:01:13 +01:00
Martchus 1ce06517cc Apply cmake-format 0.6.5 2019-12-27 01:45:30 +01:00
Martchus 3fb40baebc Reformat CMake scripts against cmake-format 0.6.3 2019-12-15 18:58:42 +01:00
Martchus 6376819c07 Apply cmake-format v0.6.0 2019-11-30 17:58:01 +01:00
Martchus 7cdfca9407 Apply cmake-format 2019-09-14 20:52:57 +02:00
Martchus ea2804f147 Allow user to append custom libs to linker line
Use-case is explained in the documentation. This implementation
takes care that the additional libs actually occur at the end
of the linker line despite the use of imported targets with
INTERFACE_LINK_LIBRARIES. It might still not be perfect but
sufficient for current use-cases.
2019-08-24 13:00:32 +02:00
Martchus f9e545abdc Remove surplus whitespace 2019-08-21 22:31:04 +02:00
Martchus e14b5bf335 Remove unused CMake variable 2019-08-20 22:08:47 +02:00
Martchus f9bd0b5987 Don't use @META_CONFIG_SUFFIX@ in APP_SPECIFIC_QT_TRANSLATION_FILES
See a40d2974e0
2019-08-09 23:20:10 +02:00
Martchus c483dcc7bf Remove obsolete code for handling static targets 2019-08-06 17:43:12 +02:00
Martchus 99bc257755 Apply cmake-format 2019-08-06 00:02:38 +02:00
Martchus d168717023 Configure install destinations already in BasicConfig.cmake
It might be already useful before the library config is applied.
2019-08-05 23:46:09 +02:00
Martchus de2d6f6d98 Improve pkg-config file generation
* Prevent imported library paths pointing to build directory
  ending up in pkg-config file
* Handle targets which reference other targets but have not pkg-config
  module
* Fix check for BUNDLED_TARGETS
2019-08-05 23:45:08 +02:00
Martchus 79855f285d Improve pkg-config file generation
* Don't refer to bundles libraries via its imported location
* Add dependencies of imported targets
2019-08-05 19:07:49 +02:00
Martchus 3d47869bcd Use META_PLUGIN_CATEGORY within build directory
The *.so file might not be found when not in the right
subdirectory.
2019-07-26 22:01:00 +02:00
Martchus eb34ce610d Add domain to ApplicationInfo 2019-07-20 20:57:56 +02:00
Martchus d184370fea Add note about project()
So I don't get the bright idea to revert recent
changes again in some future refactoring.
2019-07-20 18:04:10 +02:00
Chih-Hsuan Yen 9264f1ac76
Add icons (*.icns) for Mac OS X/macOS .app bundles 2019-07-20 12:14:30 +08:00
Chih-Hsuan Yen 6f3a1fa086
Make .app bundles work on macOS
By setting CMake variables for Info.plist generation. Some of them are
necessary and others are good to have.
2019-07-17 17:53:16 +08:00
Martchus d318585fb2 Add EXCLUDED_FILES variable
When adding source files to the _FILES variables conditionally
those are so far not being formatted or translated. Adding
these files at least to the EXCLUDED_FILES will fix this.

Replaces DOC_ONLY_FILES which served the same purpose but was
limited to documentation.
2019-07-13 14:01:25 +02:00
Chih-Hsuan Yen ee31e5c1d1
Fix building with Xcode 2019-07-13 10:22:21 +08: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 7249751d30 Apply clang-format and cmake-format 2019-06-16 16:54:26 +02:00
Martchus 869a3b2ae2 Don't try to install Qt plugins outside of the install prefix
Even if QMake tells us that would be the right location because
it breaks development setups which use a custom install prefix
and set QT_PLUGIN_PATH accordingly.
2019-06-16 16:54:00 +02:00
Martchus fc9e1ff703 Add version header to libraries 2019-06-16 15:33:10 +02:00
Martchus 5607691251 Deal with "bundled" dependencies
* Allow exporting targets from 3rd party projects which are
  built within my own projects. This is required if the build
  scripts of these 3rd party projects don't have an export on
  their own but are used in the public interface or as a dependency
  of a static library.
* Add those libraries to the pkg-config file as well.
2019-06-15 15:30:56 +02:00
Martchus fd531bdd6a Prefix most of the macros in global.h 2019-06-12 20:34:25 +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 bfdd6ada2b Disable mingw-w64 packaging specific code by default 2019-06-01 16:32:21 +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 a865522e67 Use existing TARGET_INCLUDE_DIRECTORY_BUILD_INTERFACE 2019-05-28 17:55:28 +02:00
Martchus 01f21e63c9 Fix appdata.xml.in 2019-05-19 14:14:25 +02:00
Martchus 6489cae19e Apply cmake-format 2019-05-15 15:52:29 +02:00
Martchus 1a478411d6 Default to C++17 2019-05-11 18:42:38 +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 b4cf641cfd Fix setting library version 2019-05-07 16:49:19 +02:00
Martchus a1267f2015 Fix handling undefined INTERFACE_REQUIRED_PACKAGES 2019-05-06 16:22:35 +02:00
Martchus 0443905986 Fix creation of desktop files 2019-05-05 23:19:05 +02:00
Martchus 02bd9f7c06 Add new fields to ApplicationInfo 2019-05-05 18:35:40 +02:00
Martchus fa961b21bc Adapt translatin search path to new config feature 2019-05-05 18:35:13 +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 716af584c5 Use CMakeParseArguments for add_custom_desktop_file() 2019-04-13 20:33:39 +02:00
Martchus 6088f6bb43 Don't include Qt-specific config in config.h 2019-04-13 20:33:39 +02:00
Martchus 0bd53c77b5 Query install directory for Qt plugins from qmake 2019-02-27 21:05:23 +01:00
Martchus 86f3bf8b3b Apply cmake-format 2019-02-06 17:30:52 +01:00
Martchus 42dd86a16e Support cmake-format via tidy target 2019-02-05 22:51:07 +01:00
Martchus b2bf0a002b Allow to add default cppunit test application
To get rid of the boilderplate file "cppunit.cpp" in each
project using cppunit for tests.
2019-01-13 22:14:42 +01:00
Martchus f66aa33d61 Reduce indentation in TestTarget.cmake 2019-01-13 22:01:52 +01:00
Martchus 22795dac8a Remove code for Android ECM module
Use module provided by qtutilities instead
2018-12-22 02:07:49 +01:00
Martchus b16d91287d Track dependencies of Windows resource file
So changing the icon will cause the resource file
to be recompiled.
2018-12-22 00:40:38 +01:00
Martchus 8ed1a03f92 Consider *.c and *.hpp files formattable as well 2018-12-08 19:06:01 +01:00
Martchus 2f0a7050ac Auto-detect bugtracker on Gitea 2018-12-08 19:04:48 +01:00
Martchus 26496c310e Make path of Git executable configurable 2018-12-08 19:04:01 +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 c66420b1dc Remove target to launch tests with wine
This wasn't of much use. One can just use `make
check` and set WINEPATH before manually.
2018-10-07 20:04:31 +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 3c02ad6d92 Fix check for source files 2018-09-24 22:39:09 +02:00
Martchus 3a65e3ecdd Adjust CMake modules for better Android support 2018-09-16 00:25:04 +02:00
Martchus 93d6fb5d88 Reduce indentation in ListToString 2018-07-27 16:30:11 +02:00
Martchus 35ebac1cac Add static-check target for executing clang-tidy 2018-07-27 16:19:16 +02:00
Martchus 2e2b66e398 Add mingw-w64 specific targets only when using mingw-w64 2018-07-27 16:18:27 +02:00
Martchus 6dcd39f1ac Set CXX_STANDARD on header-only lib target for Qt Creator 2018-06-26 00:05:26 +02:00
Martchus 3a6bbb0115 Allow enabling GUI config even when no specific sources present
Useful when GUI specific code is only wrapped using #ifdef so
there are no extra files.
2018-06-24 20:47:19 +02:00
Martchus 79679c0f42 Improve fake target for Qt Creator
This target is required so files for header-only libs
show up in Qt Creator. So far it was just a custom target.
However, this way include directories and build flags are
not correctly passed to the code model. So creating an
actual library now.
2018-06-24 20:43:08 +02:00
Martchus b77607f3e0 Rename META_REQUIRED_FEATURES
Because those features are actually not required.
2018-06-03 22:15:20 +02:00
Martchus 4a69db787d Allow to create header for feature detection
The header will only contain some preprocessor conditions.
CMake will *not* do checks with the current compiler.
2018-06-03 21:49:01 +02:00
Martchus 52bf075317 Move creation of srcdirref and testfiles dir to BasicConfig
Those make testing more convenient and are also useful when
there's no test target, eg. when testing syncthingtray with
mocked configuration.
2018-05-01 23:59:28 +02:00
Martchus 7cafdd551e Fix wrong negation to enable Doxygen target 2018-03-21 22:33:12 +01:00
Martchus 9a352e0b8f Do not add source files to Doxygen target
Adding the files only has the effect that the files
are shown in the IDE. However, the files should be present
anyways and adding them again causes Qt Creator to
accidently use the wrong target for the code model.
2018-03-19 20:38:10 +01:00
Martchus 19332033ec Format all GUI-only files 2018-03-11 18:58:26 +01:00
Martchus 9e8ec0fcd5 Split Qt-specific config from other config
So adding Qt-specific config does not require a change
in c++utilities anymore.
2018-03-07 18:23:51 +01:00
Martchus 8a83870ac7 Allow variable number of digits in license versions 2018-02-28 18:01:17 +01:00
Martchus d684e20bfc Add launchable to appdata.xml 2018-02-22 00:01:01 +01:00
Martchus 0dcbb3de55 Improve coding style in CMake modules 2018-02-21 23:07:51 +01:00
Martchus eea5aa57bc Fix reading version of static Qt 5 modules 2018-02-21 22:41:13 +01:00
Martchus 7c8580d579 Add license to config 2018-02-21 22:14:22 +01:00
Martchus e57e79f9c9 Stringify meta data in template 2018-02-21 22:07:05 +01:00
Martchus 486c99f7fd Determine project license automatically 2018-02-21 21:58:27 +01:00
Martchus 989d1d20c8 Allow using templated appdata body 2018-02-21 21:55:52 +01:00
Martchus 6300e37924 Install shared/static config 2018-02-19 19:45:07 +01:00
Martchus 486a09c1c5 Add basic template for meta info 2018-02-18 20:18:00 +01:00
Martchus 3fcbaf7fff Split shared and static configuration 2018-02-16 23:56:29 +01:00
Martchus 5950aed7ec Adjust use of llvm-cov to LLVM 5 2018-01-29 16:20:09 +01:00
Martchus 18e7154c03 Allow test target to be intended for manual testing
So those test targets which only setup an environment for
manual testing can be excluded from eg. `make check`.
2018-01-28 00:36:46 +01:00
Martchus a67805cb0f Allow providing a special include dir for build 2018-01-20 20:43:18 +01:00
Martchus 5c6207c6fa Do not try to strip header only libs 2018-01-20 17:44:14 +01:00
Martchus 60a762f514 Allow configuring static Qt Widget style plugins
Required since the platform styles have been
pluginized in Qt 5.10

See 4f3249f32d
2017-12-15 20:18:17 +01:00
Martchus 9744efda70 Ensure default testfiles directory for working copy exists 2017-11-17 23:36:36 +01:00
Martchus 684e97ce2a Allow customizing the config header file
by setting the 'META_CUSTOM_CONFIG' variable
2017-11-17 20:36:34 +01:00
Martchus a4e7cbd5c3 Make target 'interface_sources_for_qtcreator' unique 2017-11-16 01:59:43 +01:00
Martchus e283eea1f0 Prevent using executable of header-only lib for coverage 2017-11-15 19:13:36 +01:00
Martchus a7880e3d0c Remove *.qm files from targets when built-in translations enabled
This prevents updating *.ts files twice and in parallel leading to
build errors.
2017-11-02 00:10:06 +01:00