From 6fed9140a9a47f4dd7f1fddbe79e51c6ddb97ab6 Mon Sep 17 00:00:00 2001 From: Naresh Nayak Date: Fri, 20 Dec 2024 08:25:19 +0000 Subject: [PATCH 1/3] Updated CMake Variables for easy integration in other CMake Projects. Signed-off-by: Naresh Nayak --- CMakeLists.txt | 11 ++++------- Config.cmake.in | 3 +++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8c4511..382c657 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,13 +64,11 @@ include(CMakePackageConfigHelpers) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/Open1722Config.cmake" - INSTALL_DESTINATION "lib/cmake/Open1722" - NO_SET_AND_CHECK_MACRO - NO_CHECK_REQUIRED_COMPONENTS_MACRO) + INSTALL_DESTINATION "lib/cmake/Open1722") write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/Open1722ConfigVersion.cmake - VERSION "${Open1722_VERSION_MAJOR}.${Open1722_VERSION_MINOR}" + VERSION "${open1722_VERSION_MAJOR}.${open1722_VERSION_MINOR}" COMPATIBILITY AnyNewerVersion) install(FILES @@ -84,9 +82,8 @@ export(EXPORT Open1722Targets FILE ${CMAKE_CURRENT_BINARY_DIR}/Open1722Targets.c include(InstallRequiredSystemLibraries) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") -set(CPACK_PACKAGE_VERSION_MAJOR "${Open1722_VERSION_MAJOR}") -set(CPACK_PACKAGE_VERSION_MINOR "${Open1722_VERSION_MINOR}") -# set(CPACK_PACKAGE_DIRECTORY "${PROJECT_BINARY_DIR}/release") +set(CPACK_PACKAGE_VERSION_MAJOR "${open1722_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${open1722_VERSION_MINOR}") set(CPACK_GENERATOR "TGZ" "DEB") set(CPACK_SOURCE_GENERATOR "TGZ" "DEB") diff --git a/Config.cmake.in b/Config.cmake.in index 9c1b841..3497e29 100644 --- a/Config.cmake.in +++ b/Config.cmake.in @@ -1,3 +1,6 @@ @PACKAGE_INIT@ include("${CMAKE_CURRENT_LIST_DIR}/Open1722Targets.cmake") +set(open1722_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include") +set(open1722_LIBRARIES "@CMAKE_INSTALL_PREFIX@/lib/libopen1722.so" + "@CMAKE_INSTALL_PREFIX@/lib/libopen1722custom.so") \ No newline at end of file From 15341a67fa4a3cefab60a447d78c457183bdc7dd Mon Sep 17 00:00:00 2001 From: Naresh Nayak Date: Fri, 20 Dec 2024 09:17:54 +0000 Subject: [PATCH 2/3] Moved generation of libopen1722custom.so to src/. Signed-off-by: Naresh Nayak --- examples/CMakeLists.txt | 2 +- src/CMakeLists.txt | 10 ++++++++++ src/avtp/acf/custom/CMakeLists.txt | 10 +--------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 0400baa..8cb395f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -31,7 +31,7 @@ add_library(open1722examples STATIC "common/common.c") target_include_directories(open1722examples PRIVATE $ $ - $(CMAKE_CURRENT_SOURCE_DIR)) + ${CMAKE_CURRENT_SOURCE_DIR}) add_dependencies(examples open1722examples) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 00c00f8..b74cc2c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,8 +38,18 @@ target_include_directories(${LIB_NAME} PRIVATE $) set_target_properties(${LIB_NAME} PROPERTIES VERSION ${PROJECT_VERSION}) +add_library(${LIB_NAME}custom SHARED) +target_compile_options(${LIB_NAME}custom PRIVATE -Wall -Wextra) +target_include_directories(${LIB_NAME}custom PRIVATE + $ + $) +set_target_properties(${LIB_NAME}custom PROPERTIES VERSION ${PROJECT_VERSION}) + install(TARGETS ${LIB_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(TARGETS ${LIB_NAME}custom + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) add_subdirectory(avtp) \ No newline at end of file diff --git a/src/avtp/acf/custom/CMakeLists.txt b/src/avtp/acf/custom/CMakeLists.txt index 6fc1885..0e6b26d 100644 --- a/src/avtp/acf/custom/CMakeLists.txt +++ b/src/avtp/acf/custom/CMakeLists.txt @@ -33,14 +33,6 @@ set(LIB_NAME "${PROJECT_NAME}custom" ) file(GLOB LIB_SOURCES *.c) -add_library(${LIB_NAME} SHARED ${LIB_SOURCES}) -target_compile_options(${LIB_NAME} PRIVATE -Wall -Wextra) -target_include_directories(${LIB_NAME} PRIVATE - $ - $) -set_target_properties(${LIB_NAME} PROPERTIES VERSION ${PROJECT_VERSION}) +target_sources(${LIB_NAME} PRIVATE ${LIB_SOURCES}) -install(TARGETS ${LIB_NAME} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) From 6d7eac022229fcd505b0547ea667de4397115c11 Mon Sep 17 00:00:00 2001 From: Naresh Nayak Date: Mon, 23 Dec 2024 09:06:09 +0000 Subject: [PATCH 3/3] Handling failure of cmocka not found gracefully. Signed-off-by: Naresh Nayak --- unit/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unit/CMakeLists.txt b/unit/CMakeLists.txt index f7378a8..673a5f9 100644 --- a/unit/CMakeLists.txt +++ b/unit/CMakeLists.txt @@ -28,7 +28,12 @@ # include(CTest) -find_package(cmocka 1.1.0 REQUIRED) +find_package(cmocka 1.1.0 QUIET) + +if (NOT cmocka_FOUND) + message(STATUS "cmocka not found, tests will not be built") + return() +endif() target_compile_options(open1722 PRIVATE -coverage) target_link_options(open1722 PRIVATE -coverage)