Skip to content

Commit

Permalink
Export target as libdxfrw::libdxfrw to keep consistency with Conan pa…
Browse files Browse the repository at this point in the history
…ckages
  • Loading branch information
feragon committed Apr 11, 2020
1 parent a6e14ac commit 75c862e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 17 deletions.
28 changes: 16 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ set(installdxfrw_hdrs
set(LIBDXFRW_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/libdxfrw)

add_library(dxfrw ${libdxfrw_srcs} ${libdxfrw_hdrs})
set_target_properties(dxfrw PROPERTIES VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}")
set_target_properties(dxfrw PROPERTIES
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}"
EXPORT_NAME libdxfrw
)
target_compile_features(dxfrw PUBLIC cxx_std_11)
target_include_directories(dxfrw
PUBLIC
Expand All @@ -87,29 +91,29 @@ add_subdirectory(dwg2dxf)

# INSTALLATION
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/DXFRW)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/libdxfrw)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libdxfrw.pc.in libdxfrw.pc)

install(TARGETS dxfrw
EXPORT dxfrw-targets
EXPORT libdxfrw-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(EXPORT dxfrw-targets
FILE DXFRWTargets.cmake
NAMESPACE DXFRW::
install(EXPORT libdxfrw-targets
FILE libdxfrwTargets.cmake
NAMESPACE libdxfrw::
DESTINATION ${INSTALL_CONFIGDIR}
)

include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/DXFRWConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/DXFRWConfig.cmake
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/libdxfrwConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/libdxfrwConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/DXFRWConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/libdxfrwConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
Expand All @@ -123,7 +127,7 @@ install(FILES
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/DXFRWConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/DXFRWConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/libdxfrwConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/libdxfrwConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
)
5 changes: 0 additions & 5 deletions cmake/DXFRWConfig.cmake

This file was deleted.

5 changes: 5 additions & 0 deletions cmake/libdxfrwConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
get_filename_component(DXFRW_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

if(NOT TARGET libdxfrw::libdxfrw)
include("${DXFRW_CMAKE_DIR}/libdxfrwTargets.cmake")
endif()
33 changes: 33 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from conans import ConanFile, CMake


class LibdxfrwConan(ConanFile):
name = "libdxfrw"
version = "1.0.0"
license = "GPL2"
url = "https://github.com/LibreCAD/libdxfrw"
description = "C++ library to read/write DXF files in binary and ascii form and to read DWG from r14 to v2015"
topics = ("dxf", "dwg")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = {"shared": False}
generators = "cmake"

def source(self):
self.run("git clone --branch " + self.version + " https://github.com/LibreCAD/libdxfrw.git")

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
cmake = self._configure_cmake()
cmake.install()

def _configure_cmake(self):
cmake = CMake(self)
cmake.configure(source_folder="libdxfrw")
return cmake

def package_info(self):
self.cpp_info.libs = ["dxfrw"]

0 comments on commit 75c862e

Please sign in to comment.