Commit a515fda2 authored by Ghislain MARY's avatar Ghislain MARY

Improve CMake config-file package.

parent 2c902312
......@@ -68,8 +68,6 @@ endif()
include_directories(
include/
src/
${BELR_INCLUDE_DIRS}
${BCTOOLBOX_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
)
if(MSVC)
......
......@@ -32,28 +32,24 @@ if(NOT LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${CMAKE_CURRENT_LIST_DIR}/BelcardTargets.cmake")
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${EP_belr_CONFIG_DIR}/BelrConfig.cmake")
if(@ENABLE_SHARED@)
set(BELCARD_TARGETNAME belcard)
set(BELCARD_LIBRARIES ${BELCARD_TARGETNAME})
else()
find_package(Belr REQUIRED)
set(BELCARD_TARGETNAME belcard-static)
get_target_property(BELCARD_LIBRARIES ${BELCARD_TARGETNAME} LOCATION)
get_target_property(BELCARD_LINK_LIBRARIES ${BELCARD_TARGETNAME} INTERFACE_LINK_LIBRARIES)
if(BELCARD_LINK_LIBRARIES)
list(APPEND BELCARD_LIBRARIES ${BELCARD_LINK_LIBRARIES})
endif()
endif()
get_filename_component(BELCARD_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_target_property(BELCARD_INCLUDE_DIRS ${BELCARD_TARGETNAME} INTERFACE_INCLUDE_DIRECTORIES)
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(BELCARD_INCLUDE_DIRS "${EP_belcard_INCLUDE_DIR}")
else()
set(BELCARD_INCLUDE_DIRS "${BELCARD_CMAKE_DIR}/../../../include")
endif()
if(@ENABLE_SHARED@)
set(BELCARD_LIBRARIES belcard)
list(INSERT BELCARD_INCLUDE_DIRS 0 "${EP_belcard_INCLUDE_DIR}")
else()
set(BELCARD_LIBRARIES belcard-static)
endif()
if(BELR_FOUND)
list(APPEND BELCARD_INCLUDE_DIRS ${BELR_INCLUDE_DIRS})
list(APPEND BELCARD_LIBRARIES ${BELR_LIBRARIES})
list(INSERT BELCARD_INCLUDE_DIRS 0 "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
endif()
list(REMOVE_DUPLICATES BELCARD_INCLUDE_DIRS)
set(BELCARD_CPPFLAGS @BELCARD_CPPFLAGS@)
set(BELCARD_FOUND 1)
......@@ -47,7 +47,8 @@ bc_apply_compile_flags(BELCARD_SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTION
if(ENABLE_STATIC)
add_library(belcard-static STATIC ${BELCARD_HEADER_FILES} ${BELCARD_SOURCE_FILES_C} ${BELCARD_SOURCE_FILES_CXX})
set_target_properties(belcard-static PROPERTIES OUTPUT_NAME belcard)
target_link_libraries(belcard-static ${BELR_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES})
target_include_directories(belcard-static PUBLIC ${BELR_INCLUDE_DIRS} ${BCTOOLBOX_INCLUDE_DIRS})
target_link_libraries(belcard-static INTERFACE ${BELR_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES})
endif()
if(ENABLE_SHARED)
add_library(belcard SHARED ${BELCARD_HEADER_FILES} ${BELCARD_SOURCE_FILES_C} ${BELCARD_SOURCE_FILES_CXX})
......@@ -55,6 +56,7 @@ if(ENABLE_SHARED)
set_target_properties(belcard PROPERTIES LINK_FLAGS "-stdlib=libc++")
endif()
set_target_properties(belcard PROPERTIES VERSION ${BELCARD_SO_VERSION})
target_include_directories(belcard PUBLIC ${BELR_INCLUDE_DIRS} ${BCTOOLBOX_INCLUDE_DIRS})
target_link_libraries(belcard PRIVATE ${BELR_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES})
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment