Commit 786e104a authored by Ghislain MARY's avatar Ghislain MARY

Improve CMake config-file package.

parent 0f7b0fb1
......@@ -125,13 +125,6 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
if(MBEDTLS_FOUND)
include_directories(${MBEDTLS_INCLUDE_DIRS})
endif()
if(POLARSSL_FOUND)
include_directories(${POLARSSL_INCLUDE_DIRS})
endif()
set(BCTOOLBOX_CPPFLAGS )
if(ENABLE_STATIC)
set(BCTBX_STATIC 1)
......
......@@ -42,30 +42,38 @@ list(APPEND BcToolbox_FIND_COMPONENTS core)
list(REMOVE_DUPLICATES BcToolbox_FIND_COMPONENTS)
set(BcToolbox_FIND_REQUIRED_core TRUE)
get_filename_component(BCTOOLBOX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(BCTOOLBOX_INCLUDE_DIRS "${EP_bctoolbox_INCLUDE_DIR}")
else()
set(BCTOOLBOX_INCLUDE_DIRS "${BCTOOLBOX_CMAKE_DIR}/../../../include")
endif()
set(BCTOOLBOX_CPPFLAGS @BCTOOLBOX_CPPFLAGS@)
set(BCTOOLBOX_LDFLAGS "@LINK_FLAGS_STR@")
set(BCTOOLBOX_LIBRARIES )
foreach(comp ${BcToolbox_FIND_COMPONENTS})
string(TOUPPER ${comp} uppercomp)
if(comp STREQUAL "core")
set(targetname "bctoolbox")
set(targetname bctoolbox)
else()
set(targetname "bctoolbox-${comp}")
set(targetname bctoolbox-${comp})
endif()
if(NOT @ENABLE_SHARED@)
set(targetname "${targetname}-static")
if(@ENABLE_SHARED@)
set(BCTOOLBOX_${uppercomp}_LIBRARIES ${targetname})
else()
set(targetname ${targetname}-static)
if(TARGET ${targetname})
get_target_property(BCTOOLBOX_${uppercomp}_LIBRARIES ${targetname} LOCATION)
get_target_property(BCTOOLBOX_${uppercomp}_LINK_LIBRARIES ${targetname} INTERFACE_LINK_LIBRARIES)
if(BCTOOLBOX_${uppercomp}_LINK_LIBRARIES)
list(APPEND BCTOOLBOX_${uppercomp}_LIBRARIES ${BCTOOLBOX_${uppercomp}_LINK_LIBRARIES})
endif()
endif()
endif()
if(TARGET ${targetname})
set(BCTOOLBOX_${uppercomp}_INCLUDE_DIRS "${BCTOOLBOX_INCLUDE_DIRS}")
set(BCTOOLBOX_${uppercomp}_LIBRARIES ${targetname})
list(APPEND BCTOOLBOX_LIBRARIES ${targetname})
get_target_property(BCTOOLBOX_${uppercomp}_INCLUDE_DIRS ${targetname} INTERFACE_INCLUDE_DIRECTORIES)
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
list(INSERT BCTOOLBOX_${uppercomp}_INCLUDE_DIRS 0 "${EP_bctoolbox_INCLUDE_DIR}")
else()
list(INSERT BCTOOLBOX_${uppercomp}_INCLUDE_DIRS 0 "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
endif()
list(REMOVE_DUPLICATES BCTOOLBOX_${uppercomp}_INCLUDE_DIRS)
list(APPEND BCTOOLBOX_LIBRARIES ${BCTOOLBOX_${uppercomp}_LIBRARIES})
list(APPEND BCTOOLBOX_INCLUDE_DIRS ${BCTOOLBOX_${uppercomp}_INCLUDE_DIRS})
set(BCTOOLBOX_${uppercomp}_FOUND 1)
if(comp STREQUAL "core")
set(BCTOOLBOX_FOUND 1)
......@@ -74,5 +82,8 @@ foreach(comp ${BcToolbox_FIND_COMPONENTS})
message(FATAL_ERROR "Required bctoolbox component \"${comp}\" cannot be found")
endif()
endforeach()
if(BCTOOLBOX_INCLUDE_DIRS)
list(REMOVE_DUPLICATES BCTOOLBOX_INCLUDE_DIRS)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/BcToolboxCMakeUtils.cmake")
......@@ -57,9 +57,9 @@ bc_apply_compile_flags(BCTOOLBOX_CXX_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTI
if(ENABLE_STATIC)
add_library(bctoolbox-static STATIC ${BCTOOLBOX_SOURCE_FILES} ${BCTOOLBOX_HEADER_FILES})
target_link_libraries(bctoolbox-static ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(bctoolbox-static INTERFACE ${CMAKE_THREAD_LIBS_INIT})
if(WIN32)
target_link_libraries(bctoolbox-static "Winmm" "Ws2_32")
target_link_libraries(bctoolbox-static INTERFACE "Winmm" "Ws2_32")
endif()
set_target_properties(bctoolbox-static PROPERTIES LINKER_LANGUAGE "CXX")
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
......@@ -67,15 +67,15 @@ if(ENABLE_STATIC)
endif()
set_target_properties(bctoolbox-static PROPERTIES OUTPUT_NAME bctoolbox)
if(HAVE_LIBRT)
target_link_libraries(bctoolbox-static rt)
target_link_libraries(bctoolbox-static INTERFACE rt)
endif()
if(HAVE_LIBDL)
target_link_libraries(bctoolbox-static dl)
target_link_libraries(bctoolbox-static INTERFACE dl)
endif()
if(BCUNIT_FOUND)
add_library(bctoolbox-tester-static STATIC ${BCTOOLBOX_TESTER_SOURCE_FILES})
set_target_properties(bctoolbox-tester-static PROPERTIES OUTPUT_NAME bctoolbox-tester)
target_link_libraries(bctoolbox-tester-static bctoolbox-static)
target_link_libraries(bctoolbox-tester-static INTERFACE bctoolbox-static)
endif()
endif()
if(ENABLE_SHARED)
......@@ -137,17 +137,19 @@ endif()
if(MBEDTLS_FOUND)
if(ENABLE_STATIC)
target_include_directories(bctoolbox-static PUBLIC ${MBEDTLS_INCLUDE_DIRS})
target_link_libraries(bctoolbox-static ${MBEDTLS_LIBRARIES})
target_include_directories(bctoolbox-static PRIVATE ${BCTOOLBOX_PRIVATE_INCLUDE_DIRS})
target_link_libraries(bctoolbox-static INTERFACE ${MBEDTLS_LIBRARIES})
endif()
if(ENABLE_SHARED)
target_include_directories(bctoolbox PUBLIC ${MBEDTLS_INCLUDE_DIRS})
target_include_directories(bctoolbox PRIVATE ${BCTOOLBOX_PRIVATE_INCLUDE_DIRS})
target_link_libraries(bctoolbox PRIVATE ${MBEDTLS_LIBRARIES})
endif()
endif()
if(POLARSSL_FOUND)
if(ENABLE_STATIC)
target_include_directories(bctoolbox-static PUBLIC ${POLARSSL_INCLUDE_DIRS})
target_link_libraries(bctoolbox-static ${POLARSSL_LIBRARIES})
target_link_libraries(bctoolbox-static INTERFACE ${POLARSSL_LIBRARIES})
endif()
if(ENABLE_SHARED)
target_include_directories(bctoolbox PUBLIC ${POLARSSL_INCLUDE_DIRS})
......@@ -157,7 +159,7 @@ endif()
if(BCUNIT_FOUND)
if(ENABLE_STATIC)
target_include_directories(bctoolbox-tester-static PUBLIC ${BCUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox-tester-static bctoolbox-static ${BCUNIT_LIBRARIES})
target_link_libraries(bctoolbox-tester-static INTERFACE bctoolbox-static ${BCUNIT_LIBRARIES})
endif()
if(ENABLE_SHARED)
target_include_directories(bctoolbox-tester PUBLIC ${BCUNIT_INCLUDE_DIRS})
......
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