Makefiles already support an option to enable link time optimizations.
This is now also possible in CMake by using the WITH_LTO option.
It's turned on by default if the compiler supports these flags.
Note: LTO is part of the inter-procedural optimization (IPO).
Signed-off-by: Kai Buschulte <kai.buschulte@cedalo.com>
this makes it possible to explicitly share compile options, without
using the `add_definition` function. This function declares options for
the current directory and below (in our case also for `deps`).
Adding -Wall, -Wconversion and -Wextra to at least make compiler
warnings visible for the cmake build.
Signed-off-by: Kai Buschulte <kai.buschulte@cedalo.com>
CMake <3.19 does not support interface targets with sources.
For better IDE integrations we still can add the config.h using the
`target_sources` command.
Signed-off-by: Kai Buschulte <kai.buschulte@cedalo.com>
Use `ctest` or `make test` to run all tests.
With this it's also possible to run tests on a Mac.
Relative paths used in tests become absolute ones to make tests
executable from any build folder.
Also fixed race condition in
test/broker/11-persistent-subscription-no-local.py
Signed-off-by: Kai Buschulte <kai.buschulte@cedalo.com>
This is an interface cmake target which specifies include directories
required by the config.h places in the root of the project.
This header is a "public" header visible to plugins linking the
mosquitto exports.
Signed-off-by: Kai Buschulte <kai.buschulte@cedalo.com>
Core symbols needed by plugins are now properly linked to their objects
* Remove link_directories() call:
This specification is not necessary for our own libraries as cmake
shares this information over the targets.
If needed they should be specified target specific, like done for
the external DLT library.
Signed-off-by: Kai Buschulte <kai.buschulte@cedalo.com>
CMake >= 3.14 comes with a preinstalled FindSQLite3 module, which now
replaces the self-written one.
Signed-off-by: Kai Buschulte <kai.buschulte@cedalo.com>
When mosquitto is included as subdirectory, `CMAKE_SOURCE_DIR` does not refer to the mosquitto top level CMake file, but to the whole project top level CMake.
Use `PROJECT_SOURCE_DIR` instead to refer to the right CMake in both contextes.
Signed-off-by: Pierre Hallot <hallotpierre@gmail.com>
When using cmake to build the project, cJson discovery
should only be performed if WITH_CJSON=ON.
Closes#2026.
Signed-off-by: Boris Feinstein <madhat1@gmail.com>
The code would simply append the folder with no separator, resulting in an invalid path if the variable was not empty.
Now properly append it.
Signed-off-by: Pierre Hallot <hallotpierre@gmail.com>
https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html
"Note Call the cmake_minimum_required() command at the beginning of the top-level CMakeLists.txt file even before calling the project() command. It is important to establish version and policy settings before invoking other commands whose behavior they may affect."
Signed-off-by: Pierre Hallot <hallotpierre@gmail.com>
According to this from the mailing list, it is no longer required since the minimum cmake required is 3.0.
https://cmake.org/pipermail/cmake/2014-July/058048.html
"The code that emits the warning is run by "project()". Since you do not have an explicit project() call in your top-level CMakeLists.txt CMake adds one to the top implicitly. [1]
A project file that explicitly calls project() after requiring CMake >= 2.8.4 should make the warning go away."
Signed-off-by: Pierre Hallot <hallotpierre@gmail.com>