diff --git a/cmake/Modules/OpmDefaults.cmake b/cmake/Modules/OpmDefaults.cmake index 2e130363..b34c4206 100644 --- a/cmake/Modules/OpmDefaults.cmake +++ b/cmake/Modules/OpmDefaults.cmake @@ -1,8 +1,24 @@ # - Default settings for the build include (UseCompVer) +include(TestCXXAcceptsFlag) macro (opm_defaults opm) + # if we are installing a development version (default when checking out of + # VCS), then remember which directories were used when configuring. package + # distribution should disable this option. + option (USE_RUNPATH "Embed original dependency paths in installed library" ON) + if (USE_RUNPATH) + if (CMAKE_COMPILER_IS_GNUCXX) + check_cxx_accepts_flag ("-Wl,--enable-new-dtags" HAVE_RUNPATH) + if (HAVE_RUNPATH) + list (APPEND ${opm}_LINKER_FLAGS "-Wl,--enable-new-dtags") + endif (HAVE_RUNPATH) + endif (CMAKE_COMPILER_IS_GNUCXX) + # set this to avoid CMake stripping it off again + set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + endif (USE_RUNPATH) + # build release by default if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE "Release") diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index c9b13f8a..04a9c804 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -19,6 +19,7 @@ Optional Features: of the options shared and static may be built. --enable-debug build a non-optimized version of the library [default=no] + --disable-runpath do not use RUNPATH in installed library [default=yes] --enable-lto use whole program optimization [default=no] --disable-tests do not compile and enable unit tests [default=yes] --disable-examples do not compile example programs [default=yes] @@ -108,6 +109,8 @@ silent_rules= debug_loc= #use_lto=" -DWHOLE_PROG_OPTIM=OFF" use_lto= +#use_runpath=" -DUSE_RUNPATH=OFF" +use_runpath= #use_tests=" -DBUILD_TESTING=ON" use_tests= #use_samples=" -DBUILD_EXAMPLES=ON" @@ -235,6 +238,10 @@ for OPT in "$@"; do pch_use=" -DPRECOMPILE_HEADERS:BOOL=OFF" pkgname="" ;; + runpath) + use_runpath=" -DUSE_RUNPATH=OFF" + pkgname="" + ;; silent-rules) silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=ON" pkgname="" @@ -313,6 +320,10 @@ for OPT in "$@"; do pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON" shared="" ;; + runpath) + use_runpath=" -DUSE_RUNPATH=ON" + shared="" + ;; lto) use_lto=" -DWHOLE_PROG_OPTIM=ON" shared="" @@ -373,7 +384,7 @@ for a in "${VARS[@]}"; do done # pass everything on to CMake -CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" \"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto}${use_tests}${use_samples} ${FEATURES}" +CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" \"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto}${use_runpath}${use_tests}${use_samples} ${FEATURES}" echo --- calling CMake --- echo ${CMDLINE} eval exec ${CMDLINE} diff --git a/debian/rules b/debian/rules index d6fcf5f4..5e8d7c71 100755 --- a/debian/rules +++ b/debian/rules @@ -19,7 +19,7 @@ override_dh_auto_build: dh_auto_build --buildsystem=cmake override_dh_auto_configure: - dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_DOCDIR=share/doc/libopm-core1 -DWHOLE_PROG_OPTIM=ON + dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_DOCDIR=share/doc/libopm-core1 -DWHOLE_PROG_OPTIM=ON -DUSE_RUNPATH=OFF override_dh_auto_install: dh_auto_install -- install-html diff --git a/redhat/opm-core.spec b/redhat/opm-core.spec index 4a9622ba..0b1f85e4 100644 --- a/redhat/opm-core.spec +++ b/redhat/opm-core.spec @@ -59,7 +59,7 @@ This package contains the applications for opm-core %setup -q %build -cmake28 -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/%{name}-%{version} -DWHOLE_PROG_OPTIM=ON +cmake28 -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/%{name}-%{version} -DWHOLE_PROG_OPTIM=ON -DUSE_RUNPATH=OFF make %install