[1.5] Fix computation of relative path from include/ to lib/

This commit is contained in:
Mathieu Malaterre 2012-04-19 10:26:48 +00:00
parent b431cb0a41
commit 5379ec5715
2 changed files with 19 additions and 1 deletions

View File

@ -23,10 +23,16 @@ SET(OPENJPEG_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
SET(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
# The following is inspired from:
# http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Packaging_and_Exporting
# However the following is difficult to handle:
# get_filename_component(myproj_INCLUDE_DIRS "${SELF_DIR}/../../include/myproj" ABSOLUTE)
# it asssumes a non multi-arch system, where 'include' is located '../include' from lib
# therefore we need to take into account the number of subdirs in OPENJPEG_INSTALL_LIB_DIR
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
# This is an install tree
include(${SELF_DIR}/OpenJPEGTargets.cmake)
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/@relative_parent@/@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
else(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)

View File

@ -103,6 +103,18 @@ IF(NOT OPENJPEG_INSTALL_LIB_DIR)
SET(OPENJPEG_INSTALL_LIB_DIR "lib")
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
# The following will compute the amount of parent dir to go
# from include to lib. it works nicely with
# OPENJPEG_INSTALL_LIB_DIR=lib
# OPENJPEG_INSTALL_LIB_DIR=lib/
# OPENJPEG_INSTALL_LIB_DIR=/lib
# OPENJPEG_INSTALL_LIB_DIR=lib/gnu-linux-x64
STRING(REPLACE "/" ";" relative_to_lib ${OPENJPEG_INSTALL_LIB_DIR})
set(relative_parent "..")
foreach( elem ${relative_to_lib})
set( relative_parent "${relative_parent}/.." )
endforeach()
IF(NOT OPENJPEG_INSTALL_SHARE_DIR)
SET(OPENJPEG_INSTALL_SHARE_DIR "share")
ENDIF(NOT OPENJPEG_INSTALL_SHARE_DIR)