Skip to content
Permalink
Browse files
Fix incorrect order of cmake.definitions and cmake.configure, avoid i…
…ntrusive usage of conan in CMakeLists.txt.
  • Loading branch information
PengZheng committed Mar 17, 2022
1 parent 66724b9 commit c0c0c6d683e36768b64dfd3d62779ec5be606691
Showing 3 changed files with 9 additions and 8 deletions.
@@ -3,8 +3,7 @@
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
# "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@@ -17,7 +16,6 @@

cmake_minimum_required (VERSION 3.14)
project(test_package)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)

set(CMAKE_CXX_STANDARD 17)

@@ -32,7 +30,7 @@ target_link_libraries(framework Celix::framework)
add_celix_bundle_dependencies(framework hello)
target_compile_definitions(framework PRIVATE HELLO_TEST_BUNDLE_LOCATION="${HELLO_TEST_BUNDLE}")

option(TEST_HTTP_ADMIN "Test http_admin" ON)
option(TEST_HTTP_ADMIN "Test http_admin" OFF)
if (TEST_HTTP_ADMIN)
# make sure http_admin_api is accessible
add_celix_bundle(http_admin_sut
@@ -49,7 +47,7 @@ if (TEST_HTTP_ADMIN)
)
endif ()

option(TEST_LOG_SERVICE "Test log_admin" ON)
option(TEST_LOG_SERVICE "Test log_admin" OFF)
if (TEST_LOG_SERVICE)
add_celix_bundle(my_log_writer
SOURCES
@@ -24,14 +24,17 @@ class TestPackageConan(ConanFile):
generators = "cmake_paths"

def requirements(self):
# for test_package, `requires` is set by conan, and thus not needed
# the following make the test package can be used as a standalone package consumer
if not self.requires:
self.requires("celix/2.2.3@zhengpeng/testing")

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.definitions["TEST_HTTP_ADMIN"] = self.options["celix"].build_http_admin
cmake.definitions["TEST_LOG_SERVICE"] = self.options["celix"].build_log_service
cmake.definitions["CMAKE_PROJECT_test_package_INCLUDE"] = os.path.join(self.build_folder, "conan_paths.cmake")
cmake.configure()
cmake.build()

def test(self):
@@ -17,10 +17,10 @@
* under the License.
*/

#include "celix_api.h"
#include "celix_log_sink.h"
#define _GNU_SOURCE
#include <stdio.h>
#include "celix_api.h"
#include "celix_log_sink.h"

typedef struct my_log_writer_activator {
celix_log_sink_t logSinkSvc;

0 comments on commit c0c0c6d

Please sign in to comment.