Skip to content

Commit

Permalink
Install all project files based on GNUInstallDirs
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyLebedev authored and AnarManafov committed Dec 13, 2020
1 parent 77afcb3 commit 892e68d
Show file tree
Hide file tree
Showing 35 changed files with 90 additions and 80 deletions.
48 changes: 31 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ set(DDS_PROTOCOL_VERSION "2")
#
cmake_minimum_required( VERSION 3.11.0 FATAL_ERROR )

string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")

set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard version to use (default is 17)")
Expand Down Expand Up @@ -60,8 +62,20 @@ endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
#
# Set appropriate defaults for install subdirectories.
# Especially for correct packaging.
# Define CMAKE_INSTALL_*DIR and CMAKE_INSTALL_FULL_*DIR variables
include(GNUInstallDirs)

# Define install dirs
set(PROJECT_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
set(PROJECT_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
set(PROJECT_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME_LOWER})
set(PROJECT_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME_LOWER})
set(PROJECT_INSTALL_TESTS tests)
set(PROJECT_INSTALL_DOCDIR ${CMAKE_INSTALL_DATADIR}/doc/${PROJECT_NAME_LOWER})
set(PROJECT_INSTALL_SYSCONFDIR ${CMAKE_INSTALL_SYSCONFDIR})
set(PROJECT_INSTALL_PLUGINSDIR plugins)
set(PROJECT_INSTALL_TUTORIALSDIR tutorials)

#
# Options
#
Expand Down Expand Up @@ -157,11 +171,11 @@ endif()

set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_INSTALL_RPATH "${PROJECT_INSTALL_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_LIBDIR}" isSystemDir)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${PROJECT_INSTALL_LIBDIR}" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_INSTALL_RPATH "${PROJECT_INSTALL_LIBDIR}")
endif()

#
Expand Down Expand Up @@ -356,13 +370,13 @@ endif(BUILD_dds_tools_lib)
#
# Install
#
install(FILES ${DDS_DOC_FILES} DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES ${DDS_DOC_FILES} DESTINATION "${PROJECT_INSTALL_DOCDIR}")
install(PROGRAMS ${CMAKE_SOURCE_DIR}/etc/DDS_env.sh DESTINATION .)
# install bin files
install(PROGRAMS ${DDS_BIN_FILES} DESTINATION bin)
install(PROGRAMS ${DDS_BIN_PRIVATE_FILES} DESTINATION bin/private)
install(PROGRAMS ${DDS_BIN_FILES} DESTINATION "${PROJECT_INSTALL_BINDIR}")
install(PROGRAMS ${DDS_BIN_PRIVATE_FILES} DESTINATION "${PROJECT_INSTALL_BINDIR}/private")
# install etc files
install(FILES ${DDS_ETC_FILES} DESTINATION etc)
install(FILES ${DDS_ETC_FILES} DESTINATION "${PROJECT_INSTALL_SYSCONFDIR}")
# install share files
install(FILES ${DDS_SHARE_FILES} DESTINATION share)
# tests runner
Expand All @@ -372,20 +386,20 @@ if( BUILD_TESTS )
set(DDS_VAR_MULTIPLIER ${MULTIPLIER})
set(DDS_VAR_MAX_VALUE ${MAX_VALUE})
configure_file(${CMAKE_SOURCE_DIR}/res/tests/property_test.xml.in ${CMAKE_CURRENT_BINARY_DIR}/res/tests/${TOPO_FILE} @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/res/tests/${TOPO_FILE} DESTINATION tests)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/res/tests/${TOPO_FILE} DESTINATION "${PROJECT_INSTALL_TESTS}")
endmacro()
ddsConfigTopoPropertyTest(1 10 property_test.xml)
ddsConfigTopoPropertyTest(2 10 property_test_up.xml)
ddsConfigTopoPropertyTest(1 1000000 property_test_inf.xml)
ddsConfigTopoPropertyTest(2 1000000 property_test_inf_up.xml)

configure_file(run_test.sh.in ${CMAKE_CURRENT_BINARY_DIR}/run_test.sh @ONLY)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/run_test.sh DESTINATION tests)
install(PROGRAMS ${CMAKE_SOURCE_DIR}/res/tests/run_test_property.sh DESTINATION tests)
install(PROGRAMS ${CMAKE_SOURCE_DIR}/res/tests/run_test_property_local.sh DESTINATION tests)
install(PROGRAMS ${CMAKE_SOURCE_DIR}/res/tests/run_test_property_slurm.sh DESTINATION tests)
install(FILES ${CMAKE_SOURCE_DIR}/res/tests/env_test.xml DESTINATION tests)
install(FILES ${CMAKE_SOURCE_DIR}/res/tests/custom_cmd_test.xml DESTINATION tests)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/run_test.sh DESTINATION "${PROJECT_INSTALL_TESTS}")
install(PROGRAMS ${CMAKE_SOURCE_DIR}/res/tests/run_test_property.sh DESTINATION "${PROJECT_INSTALL_TESTS}")
install(PROGRAMS ${CMAKE_SOURCE_DIR}/res/tests/run_test_property_local.sh DESTINATION "${PROJECT_INSTALL_TESTS}")
install(PROGRAMS ${CMAKE_SOURCE_DIR}/res/tests/run_test_property_slurm.sh DESTINATION "${PROJECT_INSTALL_TESTS}")
install(FILES ${CMAKE_SOURCE_DIR}/res/tests/env_test.xml DESTINATION "${PROJECT_INSTALL_TESTS}")
install(FILES ${CMAKE_SOURCE_DIR}/res/tests/custom_cmd_test.xml DESTINATION "${PROJECT_INSTALL_TESTS}")
endif( BUILD_TESTS )


Expand Down Expand Up @@ -490,15 +504,15 @@ add_custom_target( wn_bin_upload
add_dependencies( wn_bin_upload
wn_bin )

INSTALL(FILES ${CMAKE_BINARY_DIR}/${WN_PKG_NAME_ARCH} DESTINATION bin/wn_bins OPTIONAL)
INSTALL(FILES ${CMAKE_BINARY_DIR}/${WN_PKG_NAME_ARCH} DESTINATION "${PROJECT_INSTALL_BINDIR}/wn_bins" OPTIONAL)


# WORKAROUND: don't generate helper script when building an xcode project
# The reason: "Evaluation file to be written multiple times for different configurations or languages with different content"
if (NOT CMAKE_GENERATOR STREQUAL "Xcode")
# WORKAROUND: create destination "lib" directory.
# INSTALL SCRIPT is called before any other lib is installed, therefore we need to create a dest. dir.
INSTALL(DIRECTORY DESTINATION ${CMAKE_INSTALL_LIBDIR})
INSTALL(DIRECTORY DESTINATION "${PROJECT_INSTALL_LIBDIR}")
INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/DDS_CollectPrerequisitesGen.cmake)
if( BUILD_TESTS )
INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/DDS_CollectPrerequisitesGen_Tests.cmake)
Expand Down Expand Up @@ -570,7 +584,7 @@ install(FILES
DESTINATION ${PACKAGE_INSTALL_DESTINATION}
)

install(FILES ${CMAKE_SOURCE_DIR}/dds.h DESTINATION "include/dds")
install(FILES ${CMAKE_SOURCE_DIR}/dds.h DESTINATION "${PROJECT_INSTALL_INCLUDEDIR}")

# Create a symlink to the lib dir if its location is outside of DDS_LOCATION.
# For example, when "cmake -DCMAKE_INSTALL_LIBDIR=..." is specified then the location of the lib dir can be different.
Expand Down
2 changes: 1 addition & 1 deletion MiscCommon/dds_ncf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ else()
endif()

install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION "${PROJECT_INSTALL_LIBDIR}"
)
2 changes: 1 addition & 1 deletion MiscCommon/dds_ncf/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ target_link_libraries(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION tests
RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}"
)
2 changes: 1 addition & 1 deletion MiscCommon/pipe_log_engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ target_include_directories(pipe_log_engine
)

install(TARGETS pipe_log_engine
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION "${PROJECT_INSTALL_LIBDIR}"
)
14 changes: 7 additions & 7 deletions MiscCommon/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ target_link_libraries(${test}
Boost::filesystem
)

install(TARGETS ${test} RUNTIME DESTINATION tests)
install(TARGETS ${test} RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}")

#=============================================================================

Expand All @@ -35,7 +35,7 @@ target_link_libraries(${test}
Boost::filesystem
)

install(TARGETS ${test} RUNTIME DESTINATION tests)
install(TARGETS ${test} RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}")

#=============================================================================

Expand All @@ -51,7 +51,7 @@ target_link_libraries(${test}
Boost::program_options
)

install(TARGETS ${test} RUNTIME DESTINATION tests)
install(TARGETS ${test} RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}")

#=============================================================================

Expand All @@ -67,7 +67,7 @@ target_link_libraries(${test}
Boost::filesystem
)

install(TARGETS ${test} RUNTIME DESTINATION tests)
install(TARGETS ${test} RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}")

#=============================================================================

Expand All @@ -82,7 +82,7 @@ target_link_libraries(${test}
Boost::system
)

install(TARGETS ${test} RUNTIME DESTINATION tests)
install(TARGETS ${test} RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}")

#=============================================================================

Expand All @@ -96,7 +96,7 @@ target_link_libraries(${test}
Boost::unit_test_framework
)

install(TARGETS ${test} RUNTIME DESTINATION tests)
install(TARGETS ${test} RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}")

#=============================================================================

Expand All @@ -112,4 +112,4 @@ target_link_libraries(${test}
Boost::filesystem
)

install(TARGETS ${test} RUNTIME DESTINATION tests)
install(TARGETS ${test} RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}")
2 changes: 1 addition & 1 deletion dds-agent-cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target_include_directories(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
RUNTIME DESTINATION "${PROJECT_INSTALL_BINDIR}"
)

#if(BUILD_TESTS)
Expand Down
2 changes: 1 addition & 1 deletion dds-agent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ target_include_directories(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
RUNTIME DESTINATION "${PROJECT_INSTALL_BINDIR}"
)

if(BUILD_TESTS)
Expand Down
2 changes: 1 addition & 1 deletion dds-commander/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ target_include_directories(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
RUNTIME DESTINATION "${PROJECT_INSTALL_BINDIR}"
)

if(BUILD_TESTS)
Expand Down
5 changes: 2 additions & 3 deletions dds-commander/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ target_include_directories(${test}
)

install(TARGETS ${test}
RUNTIME DESTINATION tests
RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}"
)

if(BUILD_TESTS)
install(FILES
topology_scheduler_test_1.xml
topology_scheduler_test_2.xml

DESTINATION tests
DESTINATION "${PROJECT_INSTALL_TESTS}"
)
endif()
2 changes: 1 addition & 1 deletion dds-custom-cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ target_include_directories(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
RUNTIME DESTINATION "${PROJECT_INSTALL_BINDIR}"
)

#if(BUILD_TESTS)
Expand Down
2 changes: 1 addition & 1 deletion dds-daemonize/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ target_include_directories(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
RUNTIME DESTINATION "${PROJECT_INSTALL_BINDIR}"
)

if(BUILD_TESTS)
Expand Down
2 changes: 1 addition & 1 deletion dds-info/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target_include_directories(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
RUNTIME DESTINATION "${PROJECT_INSTALL_BINDIR}"
)

#if(BUILD_TESTS)
Expand Down
4 changes: 2 additions & 2 deletions dds-intercom-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ target_include_directories(${PROJECT_NAME}

install(TARGETS ${PROJECT_NAME}
EXPORT DDSTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION "${PROJECT_INSTALL_LIBDIR}"
)
install(FILES ${SRC_HDRS} DESTINATION "include/dds")
install(FILES ${SRC_HDRS} DESTINATION "${PROJECT_INSTALL_INCLUDEDIR}")

if(BUILD_TESTS)
message(STATUS "Build ${PROJECT_NAME} tests - YES")
Expand Down
6 changes: 3 additions & 3 deletions dds-intercom-lib/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ target_link_libraries(${test}
Boost::program_options
)

install(TARGETS ${test} DESTINATION tests)
install(TARGETS ${test} DESTINATION "${PROJECT_INSTALL_TESTS}")

##################################################################
# task-test_key_value
Expand All @@ -33,7 +33,7 @@ target_link_libraries(task-test_key_value
dds_topology_lib
Boost::boost
)
install(TARGETS task-test_key_value DESTINATION tests)
install(TARGETS task-test_key_value DESTINATION "${PROJECT_INSTALL_TESTS}")

##################################################################
# task-test_custom_cmd
Expand All @@ -46,4 +46,4 @@ target_link_libraries(task-test_custom_cmd
dds_topology_lib
Boost::boost
)
install(TARGETS task-test_custom_cmd DESTINATION tests)
install(TARGETS task-test_custom_cmd DESTINATION "${PROJECT_INSTALL_TESTS}")
2 changes: 1 addition & 1 deletion dds-protocol-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ target_include_directories(${PROJECT_NAME}

install(TARGETS ${PROJECT_NAME}
EXPORT DDSTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION "${PROJECT_INSTALL_LIBDIR}"
)

if(BUILD_TESTS)
Expand Down
2 changes: 1 addition & 1 deletion dds-protocol-lib/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ target_link_libraries(${test}
Boost::unit_test_framework
)

install(TARGETS ${test} DESTINATION tests)
install(TARGETS ${test} DESTINATION "${PROJECT_INSTALL_TESTS}")
2 changes: 1 addition & 1 deletion dds-session/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ target_include_directories(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
RUNTIME DESTINATION "${PROJECT_INSTALL_BINDIR}"
)

#if(BUILD_TESTS)
Expand Down
2 changes: 1 addition & 1 deletion dds-stat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ target_include_directories(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
RUNTIME DESTINATION "${PROJECT_INSTALL_BINDIR}"
)

#if(BUILD_TESTS)
Expand Down
2 changes: 1 addition & 1 deletion dds-submit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target_include_directories(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
RUNTIME DESTINATION "${PROJECT_INSTALL_BINDIR}"
)

#if(BUILD_TESTS)
Expand Down
2 changes: 1 addition & 1 deletion dds-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ target_include_directories(${PROJECT_NAME}
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
RUNTIME DESTINATION "${PROJECT_INSTALL_BINDIR}"
)

#if(BUILD_TESTS)
Expand Down
4 changes: 2 additions & 2 deletions dds-tools-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ target_include_directories(${PROJECT_NAME}

install(TARGETS ${PROJECT_NAME}
EXPORT DDSTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION "${PROJECT_INSTALL_LIBDIR}"
)
install(FILES ${HEADER_FILES_EXT} DESTINATION "include/dds")
install(FILES ${HEADER_FILES_EXT} DESTINATION "${PROJECT_INSTALL_INCLUDEDIR}")

if(BUILD_TESTS)
message(STATUS "Build ${PROJECT_NAME} unit tests - YES")
Expand Down
6 changes: 3 additions & 3 deletions dds-tools-lib/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ target_link_libraries(dds_tools_lib-protocol-tests
install(TARGETS
dds_tools_lib-protocol-tests

RUNTIME DESTINATION tests
RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}"
)

install(FILES
test_protocol_1.json

DESTINATION tests
DESTINATION "${PROJECT_INSTALL_TESTS}"
)


Expand All @@ -45,5 +45,5 @@ target_link_libraries(dds_tools_lib-session-tests
install(TARGETS
dds_tools_lib-session-tests

RUNTIME DESTINATION tests
RUNTIME DESTINATION "${PROJECT_INSTALL_TESTS}"
)
Loading

0 comments on commit 892e68d

Please sign in to comment.