Commit 1941abda authored by Ghislain MARY's avatar Ghislain MARY

Create a CMake config-file package.

parent 354ab280
......@@ -155,11 +155,18 @@ endif()
if(ENABLE_STATIC)
add_library(bcunit STATIC ${SOURCE_FILES})
target_link_libraries(bcunit ${CURSES_LIBRARIES})
if(ANDROID)
target_link_libraries(bcunit INTERFACE "log")
endif()
if(CURSES_LIBRARIES)
target_link_libraries(bcunit INTERFACE ${CURSES_LIBRARIES})
endif()
else()
add_library(bcunit SHARED ${SOURCE_FILES})
set_target_properties(bcunit PROPERTIES VERSION 1.0.1)
target_link_libraries(bcunit ${CURSES_LIBRARIES})
if(CURSES_LIBRARIES)
target_link_libraries(bcunit ${CURSES_LIBRARIES})
endif()
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/bcunit.pdb
......@@ -169,7 +176,7 @@ else()
endif()
endif()
endif()
install(TARGETS bcunit
install(TARGETS bcunit EXPORT BcUnitTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
......
############################################################################
# BcUnitConfig.cmake.in
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
#
# Config file for the bcunit package.
#
# It defines the following variables:
#
# BCUNIT_FOUND - system has bcunit
# BCUNIT_INCLUDE_DIRS - the bcunit include directory
# BCUNIT_LIBRARIES - The libraries needed to use bcunit
include("${CMAKE_CURRENT_LIST_DIR}/BcUnitTargets.cmake")
if(@ENABLE_SHARED@)
set(BCUNIT_LIBRARIES bcunit)
else()
get_target_property(BCUNIT_LIBRARIES bcunit LOCATION)
get_target_property(BCUNIT_LINK_LIBRARIES bcunit INTERFACE_LINK_LIBRARIES)
if(BCUNIT_LINK_LIBRARIES)
list(APPEND BCUNIT_LIBRARIES ${BCUNIT_LINK_LIBRARIES})
endif()
endif()
get_target_property(BCUNIT_INCLUDE_DIRS bcunit INTERFACE_INCLUDE_DIRECTORIES)
if(NOT BCUNIT_INCLUDE_DIRS)
set(BCUNIT_INCLUDE_DIRS )
endif()
list(INSERT BCUNIT_INCLUDE_DIRS 0 "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
list(REMOVE_DUPLICATES BCUNIT_INCLUDE_DIRS)
set(BCUNIT_FOUND 1)
......@@ -100,3 +100,26 @@ add_subdirectory(Share)
if(ENABLE_EXAMPLES)
add_subdirectory(Examples)
endif()
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/BcUnitConfigVersion.cmake"
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT BcUnitTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/BcUnitTargets.cmake"
)
configure_file(BcUnitConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/BcUnitConfig.cmake" @ONLY)
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
install(EXPORT BcUnitTargets
FILE BcUnitTargets.cmake
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/BcUnitConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/BcUnitConfigVersion.cmake"
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
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