Skip to content

Commit

Permalink
Modernise the CMake build system slightly.
Browse files Browse the repository at this point in the history
 - Update the version info
 - Don't expose a private header directory as public
 - Publish an exported target

With this, it's possible to just import the installed targets.  I have a
small overlay port for vcpkg on top of this that lets me import libucl,
which is a first step towards fixing vstakhov#254.
  • Loading branch information
davidchisnall committed Aug 22, 2021
1 parent e3d6be3 commit 16e3609
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PROJECT(libucl C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0 FATAL_ERROR)

SET(LIBUCL_VERSION_MAJOR 0)
SET(LIBUCL_VERSION_MINOR 5)
SET(LIBUCL_VERSION_PATCH 0)
SET(LIBUCL_VERSION_MINOR 8)
SET(LIBUCL_VERSION_PATCH 1)

SET(LIBUCL_VERSION
"${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}")
Expand Down Expand Up @@ -237,9 +237,8 @@ ADD_LIBRARY(ucl ${LIB_TYPE} ${UCLSRC})
ADD_LIBRARY(ucl::ucl ALIAS ucl)
SET_TARGET_PROPERTIES(ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR})
TARGET_INCLUDE_DIRECTORIES(ucl
PUBLIC
include
PRIVATE
include
src
uthash
klib)
Expand Down Expand Up @@ -305,10 +304,16 @@ ENDIF(UNIX)
SET_TARGET_PROPERTIES(ucl PROPERTIES
PUBLIC_HEADER "${UCLHDR}")

INSTALL(TARGETS ucl DESTINATION ${CMAKE_INSTALL_LIBDIR}
INSTALL(TARGETS ucl EXPORT uclConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

IF(ENABLE_UTILS MATCHES "ON")
ADD_SUBDIRECTORY(utils)
ENDIF()

install(EXPORT uclConfig
FILE ucl-config.cmake
NAMESPACE ucl::
DESTINATION "share/ucl"
)

0 comments on commit 16e3609

Please sign in to comment.