This commit is contained in:
2019-04-20 15:01:11 +03:00
parent 3300089396
commit ce481c7e30
8 changed files with 107 additions and 27 deletions

View File

@ -4,10 +4,9 @@ category: Программирование
tags: программирование, cmake
summary: ""
CSS: table-100.css
documentclass: extarticle
monofont: Pragmata Pro
toc: yes
monofontoptions:
- Scale=0.7
- Scale=0.6
...
@ -127,7 +126,7 @@ ORG, Inc.
```
В файле `cmake/etc/cpack_ignore.txt` перечислить шаблоны
для исключения из создаваемого целью `dist` архива. Например:
для исключения из архива, создаваемого целью `dist`. Например:
```
cmake/lib/.git$
@ -213,7 +212,7 @@ add_subdirectory(src/libcmex)
В каталоге `cmex/src/libcmex` нужно создать файл `cmex.hpp`:
```c
```cpp
#ifndef LIBCMEX_CMEX_HPP_
#define LIBCMEX_CMEX_HPP_
@ -226,7 +225,7 @@ int32_t cmex_init(int32_t i);
файл `cmex.cpp`:
```c
```cpp
#include "cmex.hpp"
int32_t cmex_init(int32_t i = 0) {
@ -430,12 +429,24 @@ target_link_libraries(${current_target} ${CMAKE_BINARY_DIR}/lib/libcmext.a)
#include "cmex.hpp"
QTextStream& qStdOut()
{
static QTextStream ts(stdout);
return ts;
}
int main(int argc, char **argv) {
std::cout << CMEX_COMPILER_VERSION_MAJOR << std::endl; // Значение из compiler_features.hpp
std::cout << BUILD_TYPE << std::endl; // Значение из config.hpp
std::cout << CMEX_VERSION_STR << std::endl; // Значение из config.hpp
std::cout << cmex_init(4) << std::endl; // Функция из внутренней библиотеки
std::cout << cmext_init(9) << std::endl; // Функция из внешней библиотеки
// Значение из compiler_features.hpp
qStdOut() << QObject::tr("Compiler version: ") << CMEX_COMPILER_VERSION_MAJOR << endl;
// Значение из config.hpp
qStdOut() << QObject::tr("Project version: ") << CMEX_VERSION_STR << endl;
// Значение из config.hpp
qStdOut() << QObject::tr("Build type: ") << BUILD_TYPE << endl;
// Функция из внутренней библиотеки
qStdOut() << QObject::tr("libcmex function call: ") << cmex_init(4) << endl;
// Функция из внешней библиотеки
qStdOut() << QObject::tr("libcmext function call: ") << cmext_init(9) << endl;
return 0;
}
```
@ -482,6 +493,12 @@ target_link_libraries(${current_target} Qt5::Core)
#include "cmex.hpp"
QTextStream& qStdOut()
{
static QTextStream ts(stdout);
return ts;
}
int main(int argc, char **argv) {
QCoreApplication app(argc, argv);
QTranslator translator;
@ -490,11 +507,17 @@ int main(int argc, char **argv) {
{
app.installTranslator(&translator);
}
std::cout << QObject::tr("Compiler version: ").toStdString() << CMEX_COMPILER_VERSION_MAJOR << std::endl; // Значение из compiler_features.hpp
std::cout << QObject::tr("Project version: ").toStdString() << CMEX_VERSION_STR << std::endl; // Значение из config.hpp
std::cout << QObject::tr("Build type: ").toStdString() << BUILD_TYPE << std::endl; // Значение из config.hpp
std::cout << QObject::tr("libcmex function call: ").toStdString() << cmex_init(4) << std::endl; // Функция из внутренней библиотеки
std::cout << QObject::tr("libcmext function call: ").toStdString() << cmext_init(9) << std::endl; // Функция из внешней библиотеки
// Значение из compiler_features.hpp
qStdOut() << QObject::tr("Compiler version: ") << CMEX_COMPILER_VERSION_MAJOR << endl;
// Значение из config.hpp
qStdOut() << QObject::tr("Project version: ") << CMEX_VERSION_STR << endl;
// Значение из config.hpp
qStdOut() << QObject::tr("Build type: ") << BUILD_TYPE << endl;
// Функция из внутренней библиотеки
qStdOut() << QObject::tr("libcmex function call: ") << cmex_init(4) << endl;
// Функция из внешней библиотеки
qStdOut() << QObject::tr("libcmext function call: ") << cmext_init(9) << endl;
return 0;
}
```
@ -589,6 +612,12 @@ MyMainWindow::~MyMainWindow() {
#include "cmex.hpp"
#include "my_main_window.hpp"
QTextStream& qStdOut()
{
static QTextStream ts(stdout);
return ts;
}
int main(int argc, char **argv) {
QApplication app(argc, argv);
QTranslator translator;
@ -597,11 +626,17 @@ int main(int argc, char **argv) {
{
app.installTranslator(&translator);
}
std::cout << QObject::tr("Compiler version: ").toStdString() << CMEX_COMPILER_VERSION_MAJOR << std::endl; // Значение из compiler_features.hpp
std::cout << QObject::tr("Project version: ").toStdString() << CMEX_VERSION_STR << std::endl; // Значение из config.hpp
std::cout << QObject::tr("Build type: ").toStdString() << BUILD_TYPE << std::endl; // Значение из config.hpp
std::cout << QObject::tr("libcmex function call: ").toStdString() << cmex_init(4) << std::endl; // Функция из внутренней библиотеки
std::cout << QObject::tr("libcmext function call: ").toStdString() << cmext_init(9) << std::endl; // Функция из внешней библиотеки
// Значение из compiler_features.hpp
qStdOut() << QObject::tr("Compiler version: ") << CMEX_COMPILER_VERSION_MAJOR << endl;
// Значение из config.hpp
qStdOut() << QObject::tr("Project version: ") << CMEX_VERSION_STR << endl;
// Значение из config.hpp
qStdOut() << QObject::tr("Build type: ") << BUILD_TYPE << endl;
// Функция из внутренней библиотеки
qStdOut() << QObject::tr("libcmex function call: ") << cmex_init(4) << endl;
// Функция из внешней библиотеки
qStdOut() << QObject::tr("libcmext function call: ") << cmext_init(9) << endl;
MyMainWindow* mmw = new MyMainWindow();
mmw->show();