Skip to content

Commit

Permalink
Add cmake option to install PyIlmBase pkg-config file
Browse files Browse the repository at this point in the history
Signed-off-by: Cary Phillips <cary@ilm.com>
  • Loading branch information
cary-ilm committed Apr 30, 2020
1 parent 2a82f18 commit 656a3a5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions PyIlmBase/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ target_include_directories(PyIlmBaseConfig INTERFACE
install(TARGETS PyIlmBaseConfig EXPORT ${PROJECT_NAME})
add_library(PyIlmBase::Config ALIAS PyIlmBaseConfig)

if(PYILMBASE_INSTALL_PKG_CONFIG)
# use a helper function to avoid variable pollution, but pretty simple
function(pyilmbase_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_DASH ${OPENEXR_LIB_SUFFIX})
string(REPLACE ".in" "" pcout ${pcinfile})
configure_file(${pcinfile} ${CMAKE_CURRENT_BINARY_DIR}/${pcout} @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${pcout}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endfunction()
pyilmbase_pkg_config_help(../PyIlmBase.pc.in)
endif()

# The main export of the configuration - This is the
# moral equivalent of a pkg-config file for cmake
# and replaces the Find*.cmake of the "old" cmake
Expand Down
7 changes: 7 additions & 0 deletions PyIlmBase/config/PyIlmBaseSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ endif()
set(OPENEXR_CXX_STANDARD "${tmp}" CACHE STRING "C++ standard to compile against")
set(tmp)

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

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

Expand Down

0 comments on commit 656a3a5

Please sign in to comment.