Commit 15996291 authored by Ghislain MARY's avatar Ghislain MARY

Do not include dependencies in the link interface when building a shared...

Do not include dependencies in the link interface when building a shared library + Allow building both shared and static libraries.
parent 209a2e9c
......@@ -29,6 +29,10 @@ set(BELR_MICRO_VERSION "0")
set(BELR_VERSION "${BELR_MAJOR_VERSION}.${BELR_MINOR_VERSION}.${BELR_MICRO_VERSION}")
set(BELR_SO_VERSION "1")
option(ENABLE_SHARED "Build shared library." ON)
option(ENABLE_STATIC "Build static library." ON)
macro(apply_compile_flags SOURCE_FILES)
if(${SOURCE_FILES})
set(options "")
......
......@@ -33,23 +33,42 @@ apply_compile_flags(BELR_SOURCE_FILES_C "CPP" "C")
apply_compile_flags(BELR_SOURCE_FILES_CXX "CPP" "CXX")
if(ENABLE_STATIC)
add_library(belr STATIC ${BELR_HEADER_FILES} ${BELR_SOURCE_FILES_C} ${BELR_SOURCE_FILES_CXX})
else()
add_library(belr-static STATIC ${BELR_HEADER_FILES} ${BELR_SOURCE_FILES_C} ${BELR_SOURCE_FILES_CXX})
target_link_libraries(belr-static ${BCTOOLBOX_LIBRARIES})
endif()
if(ENABLE_SHARED)
add_library(belr SHARED ${BELR_HEADER_FILES} ${BELR_SOURCE_FILES_C} ${BELR_SOURCE_FILES_CXX})
if(APPLE)
set_target_properties(belr PROPERTIES LINK_FLAGS "-stdlib=libc++")
endif()
set_target_properties(belr PROPERTIES VERSION ${BELR_SO_VERSION})
target_link_libraries(belr PRIVATE ${BCTOOLBOX_LIBRARIES})
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/belr.pdb
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
endif()
endif()
target_link_libraries(belr ${BCTOOLBOX_LIBRARIES})
install(TARGETS belr EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
if(ENABLE_STATIC)
install(TARGETS belr-static EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
if(ENABLE_SHARED)
install(TARGETS belr EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
install(FILES ${BELR_HEADER_FILES}
DESTINATION include/belr
......
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