Commit 806b8b47 authored by jclamber's avatar jclamber

add rlpath to runtime linking

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@159 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent 3b2aa26d
......@@ -104,6 +104,44 @@ endif()
# SET(CMAKE_Fortran_COMPILER gfortran)
#endif()
# ----------------------------------------------------------
# Install SETUP
# ----------------------------------------------------------
mark_as_advanced(CMAKE_INSTALL_PREFIX)
IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
IF (NEMO_INSTALLED)
set (CMAKE_INSTALL_PREFIX "$ENV{NEMO}" CACHE PATH "" FORCE) #if NEMO exist => default install into NEMO path
ELSE()
set (CMAKE_INSTALL_PREFIX "$ENV{HOME}/local/unsio" CACHE PATH "" FORCE) #if NEMO NOT exist => default install into ${HOME}/local/unsio
ENDIF()
ENDIF ()#NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
MESSAGE( STATUS "--------> CMAKE_INSTALL_PREFIX =" ${CMAKE_INSTALL_PREFIX})
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
# ----------------------------------------------------------
# Executbale output path
set(EXECUTABLE_OUTPUT_PATH bin)
MESSAGE( STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH} )
......@@ -119,9 +157,7 @@ FILE(GLOB exe_sources test_src/*.F)
# ----------------------------------------------------------
# Make sure the compiler can find include files from our Hello library.
#include_directories (${UNS_SOURCE_DIR}/src $ENV{NEMOINC} ${NEMOLIB})
# compile CC programs
# Find all LIB's sources files
FILE(GLOB execpp_sources test_src/*.cc)
......@@ -134,6 +170,9 @@ FOREACH(exe_cpp ${execpp_sources})
# Link the executable to the Hello library.
target_link_libraries (${exe} unsio nemo ${SQLITE3_LIB} ${FC_GFORT_LIB} ${FC_G77_LIB} stdc++)
IF (${exe} STREQUAL "uns_info")
INSTALL(TARGETS ${exe} RUNTIME DESTINATION bin)
ENDIF()
ENDFOREACH(exe_cpp ${execpp_sources})
......@@ -161,21 +200,6 @@ endif()
# ----------------------------------------------------------
# Install procedure
# ----------------------------------------------------------
mark_as_advanced(CMAKE_INSTALL_PREFIX)
IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
IF (NEMO_INSTALLED)
set (CMAKE_INSTALL_PREFIX "$ENV{NEMO}" CACHE PATH "" FORCE) #if NEMO exist => default install into NEMO path
ELSE()
set (CMAKE_INSTALL_PREFIX "$ENV{HOME}/local/unsio" CACHE PATH "" FORCE) #if NEMO NOT exist => default install into ${HOME}/local/unsio
ENDIF()
ENDIF ()#NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
MESSAGE( STATUS "--------> CMAKE_INSTALL_PREFIX =" ${CMAKE_INSTALL_PREFIX})
# unsio lib
INSTALL(FILES ${UNSIO_BINARY_DIR}/lib/libunsio.${LIBEXT} DESTINATION lib)
# UNS specific includes
INSTALL(FILES ${UNSIO_BINARY_DIR}/../src/uns.h DESTINATION inc/uns)
......@@ -204,12 +228,16 @@ IF (NOT NEMO_INSTALLED)
ENDFOREACH()
ENDIF()
# unsio lib
INSTALL(FILES ${UNSIO_BINARY_DIR}/lib/libunsio.${LIBEXT} DESTINATION lib)
# man
INSTALL(FILES ${UNSIO_BINARY_DIR}/../man/man3/unsiof.3 DESTINATION man/man3)
# some binaries
#set (CMAKE_INSTALL_PREFIX $ENV{NEMOBIN})
INSTALL(PROGRAMS ${UNSIO_BINARY_DIR}/bin/uns_info DESTINATION bin)
#INSTALL(PROGRAMS ${UNSIO_BINARY_DIR}/bin/uns_info DESTINATION bin)
# install sqlite3 database files
INSTALL(PROGRAMS ${UNSIO_BINARY_DIR}/../scripts/perl/mains/unsio_sql3_get_info.pl DESTINATION bin)
......
......@@ -108,7 +108,41 @@ include_directories (${UNSIOPATH}/lib ${UNSIOPATH}/inc ${UNSIOPATH}/inc/uns)
# Make sure the linker can find libraries once it is built.
link_directories ( ${UNSIOPATH}/lib $ENV{PGPLOT_DIR} ${G2C_DIR} ${PROJECT_BINARY_DIR}/lib /usr/lib64 /usr/X11/lib ${FC_GFORT_PATH} ${FC_G77_PATH})
# ----------------------------------------------------------
# Install SETUP
# ----------------------------------------------------------
mark_as_advanced(CMAKE_INSTALL_PREFIX)
IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
IF (NEMO_INSTALLED)
set (CMAKE_INSTALL_PREFIX "$ENV{NEMO}" CACHE PATH "" FORCE) #if NEMO exist => default install into NEMO path
ELSE()
set (CMAKE_INSTALL_PREFIX "$ENV{HOME}/local/unsio" CACHE PATH "" FORCE) #if NEMO NOT exist => default install into ${HOME}/local/unsio
ENDIF()
ENDIF ()#NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
MESSAGE( STATUS "--------> CMAKE_INSTALL_PREFIX =" ${CMAKE_INSTALL_PREFIX})
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
# ----------------------------------------------------------
# Find all c/c++ exes sources files
FILE(GLOB execpp_sources ${PROJECT_SOURCE_DIR}/src/*.cc ${PROJECT_SOURCE_DIR}/src/*.c)
......@@ -122,7 +156,7 @@ FOREACH(exe_cpp ${execpp_sources})
#
target_link_libraries (${exe} MYutils ${FC_GFORT_LIB} ${FC_G77_LIB} unsio nemo ${SQLITE3_LIB} dl)
INSTALL(TARGETS ${exe} RUNTIME DESTINATION bin)
ENDFOREACH(exe_cpp ${execpp_sources})
......@@ -143,6 +177,7 @@ if (CMAKE_Fortran_COMPILER)
target_link_libraries (${exe} MYutils unsio nemomaing77 nemo ${SQLITE3_LIB} ${FC_LIB} stdc++)
SET_TARGET_PROPERTIES(${exe} PROPERTIES LINKER_LANGUAGE Fortran)
INSTALL(TARGETS ${exe} RUNTIME DESTINATION bin)
# add "-lstdc++"
#SET(CMAKE_Fortran_LINK_FLAGS "-L${NEMOLIB} ") #-lstdc++")
ENDFOREACH(exe_f ${exe_sources})
......@@ -151,36 +186,11 @@ endif()
# ----------------------------------------------------------
# install target
#set (CMAKE_INSTALL_PREFIX ${UNSIOPATH})
mark_as_advanced(CMAKE_INSTALL_PREFIX)
IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
IF (NEMO_INSTALLED)
set (CMAKE_INSTALL_PREFIX "$ENV{NEMO}" CACHE PATH "" FORCE) #if NEMO exist => default install into NEMO path
ELSE()
set (CMAKE_INSTALL_PREFIX ${UNSIOPATH} CACHE PATH "" FORCE) #if NEMO NOT exist => default install into ${HOME}/local/unsio
ENDIF()
ENDIF ()#NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
MESSAGE( STATUS "--------> CMAKE_INSTALL_PREFIX =" ${CMAKE_INSTALL_PREFIX})
IF (OSX) # Mac OSX
SET(SOEXT "dylib")
ELSE (OSX) # Linux
SET(SOEXT "so")
ENDIF(OSX)
#
# install bin targets c/c++
FOREACH(exe_cpp ${execpp_sources})
get_filename_component(exe ${exe_cpp} NAME_WE)
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/bin/${exe} DESTINATION bin)
ENDFOREACH(exe_cpp ${execpp_sources})
#
# install bin targets Fortran
FOREACH(exe_f ${exe_sources})
get_filename_component(exe ${exe_f} NAME_WE)
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/bin/${exe} DESTINATION bin)
ENDFOREACH(exe_f ${exe_sources})
INSTALL(FILES ${PROJECT_BINARY_DIR}/lib/libMYutils.${SOEXT} DESTINATION lib)
#
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment