[cmake] Use relative paths for dependencies inside install dir

This commit is contained in:
Matthias Hochsteger 2018-07-02 03:15:13 -07:00
parent ec3051815c
commit f098532aa1
2 changed files with 25 additions and 10 deletions

View File

@ -3,6 +3,8 @@ if(NOT CMAKE_BUILD_TYPE)
endif(NOT CMAKE_BUILD_TYPE)
cmake_minimum_required(VERSION 3.1.3)
include ( CMakePackageConfigHelpers )
if(NOT WIN32)
option( USE_NATIVE_ARCH "build which -march=native" ON)
endif(NOT WIN32)
@ -456,8 +458,19 @@ add_custom_target(uninstall
# Generate package config file
get_directory_property(NETGEN_COMPILE_DEFINITIONS COMPILE_DEFINITIONS)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/NetgenConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake @ONLY ESCAPE_QUOTES)
# use relative paths to libraries (needed on Windows/MacOS, when we provide some dependencies ourselves)
list(APPEND CONFIGURE_PATH_VARS ZLIB_INCLUDE_DIRS ZLIB_LIBRARIES)
if(USE_OCC)
list(APPEND CONFIGURE_PATH_VARS OCC_INCLUDE_DIR OCC_LIBRARIES_BIN OCC_LIBRARIES OCC_LIBRARY_DIR)
endif()
if(USE_GUI)
list(APPEND CONFIGURE_PATH_VARS TCL_INCLUDE_PATH TCL_LIBRARY TK_INCLUDE_PATH TK_LIBRARY LIBTOGL)
endif()
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/NetgenConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake INSTALL_DESTINATION ${NG_INSTALL_DIR_CMAKE}
PATH_VARS
${CONFIGURE_PATH_VARS}
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake DESTINATION ${NG_INSTALL_DIR_CMAKE} COMPONENT netgen_devel)

View File

@ -1,3 +1,5 @@
@PACKAGE_INIT@
set(NETGEN_VERSION "@NETGEN_VERSION@")
get_filename_component(NETGEN_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
@ -25,23 +27,23 @@ set(NETGEN_METIS_LIBRARY "@METIS_LIBRARY@")
set(NETGEN_MKL_LIBRARIES "@MKL_LIBRARIES@")
set(NETGEN_MPI_CXX_INCLUDE_PATH "@MPI_CXX_INCLUDE_PATH@")
set(NETGEN_MPI_CXX_LIBRARIES "@MPI_CXX_LIBRARIES@")
set(NETGEN_OCC_INCLUDE_DIR "@OCC_INCLUDE_DIR@")
set(NETGEN_OCC_LIBRARIES_BIN "@OCC_LIBRARIES_BIN@")
set(NETGEN_OCC_LIBRARIES "@OCC_LIBRARIES@")
set(NETGEN_OCC_LIBRARY_DIR "@OCC_LIBRARY_DIR@")
set(NETGEN_OCC_INCLUDE_DIR "@PACKAGE_OCC_INCLUDE_DIR@")
set(NETGEN_OCC_LIBRARIES_BIN "@PACKAGE_OCC_LIBRARIES_BIN@")
set(NETGEN_OCC_LIBRARIES "@PACKAGE_OCC_LIBRARIES@")
set(NETGEN_OCC_LIBRARY_DIR "@PACKAGE_OCC_LIBRARY_DIR@")
set(NETGEN_OPENGL_LIBRARIES "@OPENGL_LIBRARIES@")
set(NETGEN_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@")
set(NETGEN_PYTHON_INCLUDE_DIRS "@PYTHON_INCLUDE_DIRS@")
set(NETGEN_PYTHON_LIBRARIES "@PYTHON_LIBRARIES@")
set(NETGEN_TCL_INCLUDE_PATH "@TCL_INCLUDE_PATH@")
set(NETGEN_TCL_LIBRARY "@TCL_LIBRARY@")
set(NETGEN_TCL_INCLUDE_PATH "@PACKAGE_TCL_INCLUDE_PATH@")
set(NETGEN_TCL_LIBRARY "@PACKAGE_TCL_LIBRARY@")
set(NETGEN_TK_DND_LIBRARY "@TK_DND_LIBRARY@")
set(NETGEN_TK_INCLUDE_PATH "@TK_INCLUDE_PATH@")
set(NETGEN_TK_LIBRARY "@TK_LIBRARY@")
set(NETGEN_X11_X11_LIB "@X11_X11_LIB@")
set(NETGEN_X11_Xmu_LIB "@X11_Xmu_LIB@")
set(NETGEN_ZLIB_INCLUDE_DIRS "@ZLIB_INCLUDE_DIRS@")
set(NETGEN_ZLIB_LIBRARIES "@ZLIB_LIBRARIES@")
set(NETGEN_ZLIB_INCLUDE_DIRS "@PACKAGE_ZLIB_INCLUDE_DIRS@")
set(NETGEN_ZLIB_LIBRARIES "@PACKAGE_ZLIB_LIBRARIES@")
set(NETGEN_USE_GUI @USE_GUI@)
set(NETGEN_USE_PYTHON @USE_PYTHON@)