Skip to content

Commit

Permalink
Normalize library naming between cmake and autoconf
Browse files Browse the repository at this point in the history
installed libraries should follow the following basic pattern:
(-> indicates a symlink)

libFoo.so -> libFoo-LIB_SUFFIX.so
libFoo-LIB_SUFFIX.so -> libFoo-LIB_SUFFIX.so.MAJ_SO_VERSION
libFoo-LIB_SUFFIX.so.MAJ_SO_VERSION ->
libFoo-LIB_SUFFIX.so.FULL_SO_VERSION

so with a concrete example of 2.3 lib w/ so version of 24

libFoo.so -> libFoo-2_3.so
libFoo-2_3.so -> libFoo-2_3.so.24
libFoo-2_3.so.24 -> libFoo-2_3.so.24.0.0
libFoo-2_3.so.24.0.0.0 <--- actual file

(there may be slight variations in the link destinations based on
differences in libtool and cmake, but the file names available should
all be there)

Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
  • Loading branch information
kdt3rd committed Aug 10, 2019
1 parent d25fe81 commit 74d8b38
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions IlmBase/Half/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ lib_LTLIBRARIES = libHalf.la
libHalf_la_SOURCES = half.cpp half.h halfFunction.h halfLimits.h

libHalf_la_LDFLAGS = -version-info @LIBTOOL_VERSION@ -no-undefined
if LIB_SUFFIX_EXISTS
libHalf_la_LDFLAGS += -release @LIB_SUFFIX@
endif

libHalfincludedir = $(includedir)/OpenEXR

Expand Down
2 changes: 1 addition & 1 deletion IlmBase/IlmBase.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
libsuffix=@LIB_SUFFIX@
libsuffix=@LIB_SUFFIX_DASH@
Name: IlmBase
Description: Base math and exception libraries
Version: @ILMBASE_VERSION@
Expand Down
6 changes: 3 additions & 3 deletions IlmBase/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckLibraryExists)
include(CheckStructHasMember)
include(CMakeDependentOption)

check_include_files(ucontext.h ILMBASE_HAVE_UCONTEXT_H)
if(ILMBASE_HAVE_UCONTEXT_H)
Expand Down Expand Up @@ -73,15 +72,14 @@ install(
install(TARGETS IlmBaseConfig EXPORT ${PROJECT_NAME})
add_library(IlmBase::Config ALIAS IlmBaseConfig)

cmake_dependent_option(ILMBASE_INSTALL_PKG_CONFIG "Install IlmBase.pc file" ON "WIN32" OFF)
if(ILMBASE_INSTALL_PKG_CONFIG)
# use a helper function to avoid variable pollution, but pretty simple
function(ilmbase_pkg_config_help pcinfile)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_BINDIR})
set(libdir ${CMAKE_INSTALL_LIBDIR})
set(includedir ${CMAKE_INSTALL_INCLUDEDIR})
set(LIB_SUFFIX ${ILMBASE_LIB_SUFFIX})
set(LIB_SUFFIX_DASH ${ILMBASE_LIB_SUFFIX})
if(TARGET Threads::Threads)
# hrm, can't use properties as they end up as generator expressions
# which don't seem to evaluate
Expand All @@ -98,6 +96,8 @@ if(ILMBASE_INSTALL_PKG_CONFIG)
)
endfunction()
ilmbase_pkg_config_help(../IlmBase.pc.in)
else()
message(NOTICE "-- WARNING pkg-config generation disabled")
endif()

# The main export of the configuration - This is the
Expand Down
7 changes: 7 additions & 0 deletions IlmBase/config/IlmBaseSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ set(ILMBASE_IEX_NAMESPACE "Iex" CACHE STRING "Public namespace alias for Iex")
set(ILMBASE_ILMTHREAD_NAMESPACE "IlmThread" CACHE STRING "Public namespace alias for IlmThread")
set(ILMBASE_PACKAGE_NAME "IlmBase ${ILMBASE_VERSION}" CACHE STRING "Public string / label for displaying package")

# Whether to generate and install a pkg-config file IlmBase.pc on
if(WIN32)
option(ILMBASE_INSTALL_PKG_CONFIG "Install IlmBase.pc file" OFF)
else()
option(ILMBASE_INSTALL_PKG_CONFIG "Install IlmBase.pc file" ON)
endif()

########################
## Build related options

Expand Down
8 changes: 8 additions & 0 deletions IlmBase/config/LibraryDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ function(ILMBASE_DEFINE_LIBRARY libname)
PUBLIC_HEADER
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${ILMBASE_OUTPUT_SUBDIR}
)
if(BUILD_SHARED_LIBS AND (NOT "${ILMBASE_LIB_SUFFIX}" STREQUAL ""))
set(verlibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${ILMBASE_LIB_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})
set(baselibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${CMAKE_SHARED_LIBRARY_SUFFIX})
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_INSTALL_FULL_LIBDIR} ${CMAKE_COMMAND} -E create_symlink ${verlibname} ${baselibname})")
install(CODE "message(\"-- Creating symlink in ${CMAKE_INSTALL_FULL_LIBDIR} ${baselibname} -> ${verlibname}\")")
set(verlibname)
set(baselibname)
endif()

if(ILMBASE_BUILD_BOTH_STATIC_SHARED)
if(use_objlib)
Expand Down

0 comments on commit 74d8b38

Please sign in to comment.