From 94cb28d492ec47143e27d349900a948d0bb69e8f Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Sat, 11 Apr 2020 16:14:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=BD=D0=B5=D1=88=D0=BD=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 +++ CMakeLists.txt | 13 +++++++++++++ src/cmlib-example/CMakeLists.txt | 10 ++++++++++ src/cmlib-example/main.cpp | 23 ++--------------------- thirdparty/cmlib-example-library | 1 + 5 files changed, 29 insertions(+), 21 deletions(-) create mode 160000 thirdparty/cmlib-example-library diff --git a/.gitmodules b/.gitmodules index af0c3dd..e928fa3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "cmake/etc/uncrustify"] path = cmake/etc/uncrustify url = https://git.246060.ru/f1x1t/uncrustify-config.git +[submodule "thirdparty/cmlib-example-library"] + path = thirdparty/cmlib-example-library + url = git@git.246060.ru:/f1x1t/cmlib-example-library diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f17659..29f41fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,19 @@ find_package(Boost 1.55.0 REQUIRED COMPONENTS headers) # Автоматически генерируемый заголовочный файл cmlib_config_hpp_generate() +# Подключение внешних проектов +include(ExternalProject) + +ExternalProject_Add(ext-lib + EXCLUDE_FROM_ALL TRUE + SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/cmlib-example-library + INSTALL_DIR ${CMAKE_BINARY_DIR} + DOWNLOAD_COMMAND "" + BUILD_BYPRODUCTS /lib/libcmext.a + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_BUILD_TYPE=Release + ) + + # Приложение add_subdirectory(src/cmlib-example) diff --git a/src/cmlib-example/CMakeLists.txt b/src/cmlib-example/CMakeLists.txt index 1c903dd..32ca893 100644 --- a/src/cmlib-example/CMakeLists.txt +++ b/src/cmlib-example/CMakeLists.txt @@ -11,6 +11,16 @@ common_target_properties(${TRGT}) # Добавление к пути поиска заголовочных файлов target_include_directories(${TRGT} SYSTEM PUBLIC ${Boost_INCLUDE_DIRS}) +# Зависимость от библиотеки из внешнего проекта проекта +add_dependencies(${TRGT} ext-lib) + +# Добавление каталога, в который устанавливаются заголовочные файлы +# от внешнего проекта, к списку путей для поиска +target_include_directories(${TRGT} PUBLIC $) + +# Компоновка с библиотекой из внешнего проекта +target_link_libraries(${TRGT} ${CMAKE_BINARY_DIR}/lib/libcmlib-example.a) + # Имя целевого каталога и выходного файла для цели set_target_properties(${TRGT} PROPERTIES diff --git a/src/cmlib-example/main.cpp b/src/cmlib-example/main.cpp index 0b10770..e6adde8 100644 --- a/src/cmlib-example/main.cpp +++ b/src/cmlib-example/main.cpp @@ -1,29 +1,10 @@ -#include "compiler_features.hpp" -#include "cmlib_private_config.hpp" +#include #include -#include - -int32_t nsum(int32_t i = 0) -{ - int32_t s = 0; - for ( auto r : boost::counting_range( 1, i ) ) - { - s += r; - } - return s; -} int main(int argc, char* argv[]) { - // Значение из compiler_features.hpp - std::cout << CMLIB_EXAMPLE_APP_COMPILER_VERSION_MAJOR << std::endl; - // Значение из cmlib_private_config.hpp - std::cout << CMLIB_BUILD_TYPE << std::endl; - // Значение из cmlib_private_config.hpp - std::cout << CMLIB_BUILD_DATE << std::endl; - - auto s = nsum( argc ); + auto s = cmlib_example_init( argc ); std::cout << s << std::endl; return ( s ); diff --git a/thirdparty/cmlib-example-library b/thirdparty/cmlib-example-library new file mode 160000 index 0000000..d38b717 --- /dev/null +++ b/thirdparty/cmlib-example-library @@ -0,0 +1 @@ +Subproject commit d38b717e1b9d0169e404cc9fcc78d394c74638a6