Commit 8728bd3d authored by Nicolas Michon's avatar Nicolas Michon

make changes for cross-compilation and better use of imported targets

parent 6b07dd89
......@@ -27,13 +27,18 @@
# BCMATROSKA2_INCLUDE_DIRS - the BcMatroska2 include directory
# BCMATROSKA2_LIBRARIES - The libraries needed to use BcMatroska2
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/BcMatroska2Targets.cmake")
set(BCMATROSKA2_TARGETNAME "bcmatroska2")
if(@ENABLE_SHARED@)
set(BCMATROSKA2_LIBRARIES bcmatroska2)
set(BCMATROSKA2_LIBRARIES "${BCMATROSKA2_TARGETNAME}")
else()
get_target_property(BCMATROSKA2_LIBRARIES bcmatroska2-static LOCATION)
get_target_property(BCMATROSKA2_LIBRARIES ${BCMATROSKA2_TARGETNAME} LOCATION)
endif()
set(BCMATROSKA2_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
set(BCMATROSKA2_FOUND 1)
......@@ -20,7 +20,7 @@
#
############################################################################
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.1)
project(bcmatroska2
VERSION 0.23
......@@ -77,6 +77,8 @@ install(FILES ${CMAKE_BINARY_DIR}/config.h
)
include(CMakePackageConfigHelpers)
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
write_basic_package_version_file(
${CMAKE_BINARY_DIR}/BcMatroska2ConfigVersion.cmake
VERSION ${MATROSKA2_VERSION}
......@@ -87,12 +89,12 @@ export(EXPORT BcMatroska2Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/BcMatroska2Targets.cmake"
)
configure_file(BcMatroska2Config.cmake.in
${CMAKE_BINARY_DIR}/BcMatroska2Config.cmake
@ONLY
configure_package_config_file(BcMatroska2Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/BcMatroska2Config.cmake"
INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION}
NO_SET_AND_CHECK_MACRO
)
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
install(EXPORT BcMatroska2Targets
FILE BcMatroska2Targets.cmake
DESTINATION ${CONFIG_PACKAGE_LOCATION}
......
......@@ -33,17 +33,17 @@ endif()
string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")
if(ENABLE_STATIC)
add_library(bcmatroska2-static STATIC $<TARGET_OBJECTS:corec-objects> $<TARGET_OBJECTS:ebml2-objects> ${MATROSKA2_SOURCE_FILES})
set_target_properties(bcmatroska2-static PROPERTIES OUTPUT_NAME bcmatroska2)
set_target_properties(bcmatroska2-static PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
add_library(bcmatroska2 STATIC $<TARGET_OBJECTS:corec-objects> $<TARGET_OBJECTS:ebml2-objects> ${MATROSKA2_SOURCE_FILES})
set_target_properties(bcmatroska2 PROPERTIES OUTPUT_NAME bcmatroska2)
set_target_properties(bcmatroska2 PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
if(NOT "${LINK_FLAGS_STR}" STREQUAL "")
set_target_properties(bcmatroska2-static PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
set_target_properties(bcmatroska2 PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
endif()
target_include_directories(bcmatroska2-static PRIVATE ../libebml2 .)
target_include_directories(bcmatroska2 PRIVATE ../libebml2 .)
if(LIBS)
target_link_libraries(bcmatroska2-static ${LIBS})
target_link_libraries(bcmatroska2 ${LIBS})
endif()
install(TARGETS bcmatroska2-static EXPORT BcMatroska2Targets
install(TARGETS bcmatroska2 EXPORT BcMatroska2Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
......
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