feat: add CMake build configuration and unit tests for XRabbitMQClient
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# Avoid multiple calls to find_package to append duplicated properties to the targets
|
||||
include_guard()########### VARIABLES #######################################################################
|
||||
#############################################################################################
|
||||
set(simpleamqpclient_FRAMEWORKS_FOUND_RELEASE "") # Will be filled later
|
||||
conan_find_apple_frameworks(simpleamqpclient_FRAMEWORKS_FOUND_RELEASE "${simpleamqpclient_FRAMEWORKS_RELEASE}" "${simpleamqpclient_FRAMEWORK_DIRS_RELEASE}")
|
||||
|
||||
set(simpleamqpclient_LIBRARIES_TARGETS "") # Will be filled later
|
||||
|
||||
|
||||
######## Create an interface target to contain all the dependencies (frameworks, system and conan deps)
|
||||
if(NOT TARGET simpleamqpclient_DEPS_TARGET)
|
||||
add_library(simpleamqpclient_DEPS_TARGET INTERFACE IMPORTED)
|
||||
endif()
|
||||
|
||||
set_property(TARGET simpleamqpclient_DEPS_TARGET
|
||||
APPEND PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
$<$<CONFIG:Release>:${simpleamqpclient_FRAMEWORKS_FOUND_RELEASE}>
|
||||
$<$<CONFIG:Release>:${simpleamqpclient_SYSTEM_LIBS_RELEASE}>
|
||||
$<$<CONFIG:Release>:rabbitmq-c::rabbitmq-c>)
|
||||
|
||||
####### Find the libraries declared in cpp_info.libs, create an IMPORTED target for each one and link the
|
||||
####### simpleamqpclient_DEPS_TARGET to all of them
|
||||
conan_package_library_targets("${simpleamqpclient_LIBS_RELEASE}" # libraries
|
||||
"${simpleamqpclient_LIB_DIRS_RELEASE}" # package_libdir
|
||||
"${simpleamqpclient_BIN_DIRS_RELEASE}" # package_bindir
|
||||
"${simpleamqpclient_LIBRARY_TYPE_RELEASE}"
|
||||
"${simpleamqpclient_IS_HOST_WINDOWS_RELEASE}"
|
||||
simpleamqpclient_DEPS_TARGET
|
||||
simpleamqpclient_LIBRARIES_TARGETS # out_libraries_targets
|
||||
"_RELEASE"
|
||||
"simpleamqpclient" # package_name
|
||||
"${simpleamqpclient_NO_SONAME_MODE_RELEASE}") # soname
|
||||
|
||||
# FIXME: What is the result of this for multi-config? All configs adding themselves to path?
|
||||
set(CMAKE_MODULE_PATH ${simpleamqpclient_BUILD_DIRS_RELEASE} ${CMAKE_MODULE_PATH})
|
||||
|
||||
########## GLOBAL TARGET PROPERTIES Release ########################################
|
||||
set_property(TARGET simpleamqpclient::simpleamqpclient
|
||||
APPEND PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
$<$<CONFIG:Release>:${simpleamqpclient_OBJECTS_RELEASE}>
|
||||
$<$<CONFIG:Release>:${simpleamqpclient_LIBRARIES_TARGETS}>
|
||||
)
|
||||
|
||||
if("${simpleamqpclient_LIBS_RELEASE}" STREQUAL "")
|
||||
# If the package is not declaring any "cpp_info.libs" the package deps, system libs,
|
||||
# frameworks etc are not linked to the imported targets and we need to do it to the
|
||||
# global target
|
||||
set_property(TARGET simpleamqpclient::simpleamqpclient
|
||||
APPEND PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
simpleamqpclient_DEPS_TARGET)
|
||||
endif()
|
||||
|
||||
set_property(TARGET simpleamqpclient::simpleamqpclient
|
||||
APPEND PROPERTY INTERFACE_LINK_OPTIONS
|
||||
$<$<CONFIG:Release>:${simpleamqpclient_LINKER_FLAGS_RELEASE}>)
|
||||
set_property(TARGET simpleamqpclient::simpleamqpclient
|
||||
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
$<$<CONFIG:Release>:${simpleamqpclient_INCLUDE_DIRS_RELEASE}>)
|
||||
# Necessary to find LINK shared libraries in Linux
|
||||
set_property(TARGET simpleamqpclient::simpleamqpclient
|
||||
APPEND PROPERTY INTERFACE_LINK_DIRECTORIES
|
||||
$<$<CONFIG:Release>:${simpleamqpclient_LIB_DIRS_RELEASE}>)
|
||||
set_property(TARGET simpleamqpclient::simpleamqpclient
|
||||
APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS
|
||||
$<$<CONFIG:Release>:${simpleamqpclient_COMPILE_DEFINITIONS_RELEASE}>)
|
||||
set_property(TARGET simpleamqpclient::simpleamqpclient
|
||||
APPEND PROPERTY INTERFACE_COMPILE_OPTIONS
|
||||
$<$<CONFIG:Release>:${simpleamqpclient_COMPILE_OPTIONS_RELEASE}>)
|
||||
|
||||
########## For the modules (FindXXX)
|
||||
set(simpleamqpclient_LIBRARIES_RELEASE simpleamqpclient::simpleamqpclient)
|
||||
Reference in New Issue
Block a user