Skip to content

Commit

Permalink
Installation Folder & rpath urls (#103)
Browse files Browse the repository at this point in the history
* installation folder consistency Linux/Mac/Windows solved
* RPath issues solved for Linux/Mac
* cmake version upgraded to 3.0
  • Loading branch information
gabyx authored and acki-m committed Jan 25, 2018
1 parent 4a0272e commit 29e6ff9
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 69 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
build
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ install:
#######################################################################################
- |
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
CMAKE_URL="http://www.cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz"
CMAKE_URL="http://www.cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz"
mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
else
Expand Down
66 changes: 52 additions & 14 deletions CMake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,68 @@ set(README_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(LICENSE_FILE "${CMAKE_SOURCE_DIR}/LICENSE.txt")

# dirs where the binaries should be placed, installed
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_EXECUTABLE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(RTTR_INSTALL_DIR "${CMAKE_BINARY_DIR}/install")

# here we specify the installation directory
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install" CACHE PATH "RTTR install prefix" FORCE)
endif()

# in order to group in visual studio the targets into solution filters
set_property( GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

#3rd part dependencies dirs
set(RTTR_3RD_PARTY_DIR "${CMAKE_SOURCE_DIR}/3rd_party")

getNameOfDir(CMAKE_LIBRARY_OUTPUT_DIRECTORY RTTR_TARGET_BIN_DIR)
is_vs_based_build(VS_BUILD)
if (VS_BUILD)
#set(RTTR_BIN_INSTALL_DIR ${RTTR_TARGET_BIN_DIR}/\${CMAKE_INSTALL_CONFIG_NAME})
set(RTTR_BIN_INSTALL_DIR ${RTTR_TARGET_BIN_DIR})
set(RTTR_LIB_INSTALL_DIR "lib")
else()
set(RTTR_BIN_INSTALL_DIR ${RTTR_TARGET_BIN_DIR})
set(RTTR_LIB_INSTALL_DIR "lib")

# set all install directories for the targets
if(UNIX)
include(GNUInstallDirs)
set(RTTR_RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
set(RTTR_LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(RTTR_ARCHIVE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(RTTR_FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")

set(RTTR_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")

set(RTTR_CMAKE_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/rttr/cmake")
set(RTTR_ADDITIONAL_FILES_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/rttr")

else(WINDOWS)
set(RTTR_RUNTIME_INSTALL_DIR "bin")
set(RTTR_LIBRARY_INSTALL_DIR "bin")
set(RTTR_ARCHIVE_INSTALL_DIR "lib")
set(RTTR_FRAMEWORK_INSTALL_DIR "bin")

set(RTTR_CMAKE_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/cmake")
set(RTTR_ADDITIONAL_FILES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
endif()

set(CMAKE_DEBUG_POSTFIX "_d")

# set the rpath for executables
set(CMAKE_SKIP_BUILD_RPATH OFF) # use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF) # when building, don't use the install RPATH already (but later on when installing)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF) # NO automatic rpath for INSTALL
if(APPLE)
set(MACOSX_RPATH ON CACHE STRING "Set this to off if you dont want @rpath in install names") # uses a install name @rpath/... for libraries
set(RTTR_EXECUTABLE_INSTALL_RPATH "${RTTR_INSTALL_FULL_LIBDIR};@executable_path")
# the executable is relocatable, since the library builds with and install name "@rpath/librttr_core.0.9.6.dylib"
# the executable links
elseif(UNIX)
set(RTTR_EXECUTABLE_INSTALL_RPATH "${RTTR_INSTALL_FULL_LIBDIR};$ORIGIN")
elseif(WINDOWS)
# no such thin as rpath exists,
set(RTTR_EXECUTABLE_INSTALL_RPATH ${RTTR_INSTALL_BINDIR}) # default, has no effect
endif()



# detect architecture
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(RTTR_NATIVE_ARCH 64)
Expand Down Expand Up @@ -100,7 +138,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")
message(WARNING "clang support is currently experimental")

set(CLANG_STATIC_LINKER_FLAGS "-stdlib=libstdc++ -static -lstdc++")
set(CLANG_STATIC_LINKER_FLAGS "-stdlib=libc++ -static-libstdc++")
endif()

if(MSVC)
Expand Down Expand Up @@ -134,10 +172,10 @@ write_basic_package_version_file(

if (BUILD_INSTALLER)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CMake/rttr-config-version.cmake"
DESTINATION cmake
DESTINATION ${RTTR_CMAKE_CONFIG_INSTALL_DIR}
COMPONENT Devel)

install(FILES "${LICENSE_FILE}" "${README_FILE}"
DESTINATION "."
PERMISSIONS OWNER_READ)
DESTINATION ${RTTR_ADDITIONAL_FILES_INSTALL_DIR}
PERMISSIONS OWNER_READ)
endif()
3 changes: 1 addition & 2 deletions CMake/utility.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -504,5 +504,4 @@ macro(generateLibraryVersionVariables MAJOR MINOR PATCH PRODUCT_NAME PRODUCT_CPY
set(LIBRARY_PRODUCT_NAME ${PRODUCT_NAME})
set(LIBRARY_COPYRIGHT ${PRODUCT_CPY_RIGHT})
set(LIBRARY_LICENSE ${PRODUCT_LICENSE})
endmacro()

endmacro()
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# the build configuration options are initialized. #
####################################################################################

cmake_minimum_required (VERSION 2.8.12)
cmake_minimum_required (VERSION 3.0)

project ("rttr")

Expand Down Expand Up @@ -85,8 +85,3 @@ add_subdirectory(src)
if (BUILD_DOCUMENTATION)
add_subdirectory(doc)
endif()

# here we specify the installation directory
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${RTTR_INSTALL_DIR} CACHE PATH "RTTR install prefix" FORCE)
endif()
34 changes: 25 additions & 9 deletions src/benchmarks/bench_method/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ if(MSVC)
endif()

set_target_properties(bench_method PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")
add_dependencies(bench_method RTTR::Core)

install(TARGETS bench_method
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})

###############################################################################

Expand All @@ -78,12 +82,16 @@ if (BUILD_STATIC)
endif()

set_target_properties(bench_method_lib PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_method_lib RTTR::Core_Lib)

install(TARGETS bench_method_lib
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})
endif()

###############################################################################
Expand All @@ -103,8 +111,9 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

set_target_properties(bench_method_s PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")

FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_method_s RTTR::Core_STL)

if (MSVC)
Expand All @@ -118,7 +127,10 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

install(TARGETS bench_method_s
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})

if (BUILD_STATIC)
add_executable(bench_method_lib_s ${SRC_FILES} ${HPP_FILES})
Expand All @@ -135,7 +147,8 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

set_target_properties(bench_method_lib_s PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_method_lib_s RTTR::Core_Lib_STL)

Expand All @@ -150,7 +163,10 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

install(TARGETS bench_method_lib_s
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})
endif()
endif()

Expand Down
33 changes: 24 additions & 9 deletions src/benchmarks/bench_rttr_cast/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ target_compile_definitions(bench_rttr_cast PUBLIC BOOST_ALL_NO_LIB)
if(MSVC)
set_target_properties(bench_rttr_cast PROPERTIES COMPILE_FLAGS "/Zm200")
endif()

set_target_properties(bench_rttr_cast PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_rttr_cast RTTR::Core)

install(TARGETS bench_rttr_cast
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR} )
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})

###############################################################################

Expand All @@ -79,12 +82,16 @@ if (BUILD_STATIC)
endif()

set_target_properties(bench_rttr_cast_lib PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_rttr_cast_lib RTTR::Core_Lib)

install(TARGETS bench_rttr_cast_lib
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})
endif()

###############################################################################
Expand All @@ -104,7 +111,8 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

set_target_properties(bench_rttr_cast_s PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_rttr_cast_s RTTR::Core_STL)

Expand All @@ -119,7 +127,10 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

install(TARGETS bench_rttr_cast_s
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})

if (BUILD_STATIC)
add_executable(bench_rttr_cast_lib_s ${SRC_FILES} ${HPP_FILES})
Expand All @@ -136,7 +147,8 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

set_target_properties(bench_rttr_cast_lib_s PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_rttr_cast_lib_s RTTR::Core_Lib_STL)

Expand All @@ -151,7 +163,10 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

install(TARGETS bench_rttr_cast_lib_s
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})
endif()
endif()

Expand Down
32 changes: 24 additions & 8 deletions src/benchmarks/bench_variant/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ if(MSVC)
endif()

set_target_properties(bench_variant PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_variant RTTR::Core)

install(TARGETS bench_variant
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})

###############################################################################

Expand All @@ -79,12 +83,16 @@ if (BUILD_STATIC)
endif()

set_target_properties(bench_variant_lib PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_variant_lib RTTR::Core_Lib)

install(TARGETS bench_variant_lib
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})
endif()

###############################################################################
Expand All @@ -104,7 +112,8 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

set_target_properties(bench_variant_s PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_variant_s RTTR::Core_STL)

Expand All @@ -119,7 +128,10 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

install(TARGETS bench_variant_s
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})

if (BUILD_STATIC)
add_executable(bench_variant_lib_s ${SRC_FILES} ${HPP_FILES})
Expand All @@ -136,7 +148,8 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

set_target_properties(bench_variant_lib_s PROPERTIES DEBUG_POSTFIX _d
FOLDER "Benchmarks")
FOLDER "Benchmarks"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")

add_dependencies(bench_variant_lib_s RTTR::Core_Lib_STL)

Expand All @@ -151,7 +164,10 @@ if (BUILD_WITH_STATIC_RUNTIME_LIBS)
endif()

install(TARGETS bench_variant_lib_s
RUNTIME DESTINATION ${RTTR_BIN_INSTALL_DIR})
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})
endif()
endif()

Expand Down
3 changes: 2 additions & 1 deletion src/examples/json_serialization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ add_executable(json_serialization ${SRC_FILES} ${HPP_FILES})
target_link_libraries(json_serialization RTTR::Core)
target_include_directories(json_serialization PUBLIC ${RAPID_JSON_DIR})
set_target_properties(json_serialization PROPERTIES DEBUG_POSTFIX _d
FOLDER "Examples")
FOLDER "Examples"
INSTALL_RPATH "${RTTR_EXECUTABLE_INSTALL_RPATH}")


message(STATUS "Scanning " ${PROJECT_NAME} " module finished!")
Expand Down
Loading

0 comments on commit 29e6ff9

Please sign in to comment.