From e43bdb73c73931d73c4ec95ad2969a07f8cc3ce9 Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Sun, 17 Nov 2019 21:27:45 +0100 Subject: [PATCH] Fix install dir of CycloneDDSConfig.cmake (#321) Installing Cyclone DDS for multiple architectures with the same installation prefix gave problems because the CMake configuration files ended up overwriting each other. This brings it in line with the recommended locations. Thanks to @hansfn. Signed-off-by: Erik Boasson --- .travis.yml | 14 +++++++++----- README.md | 9 ++++----- appveyor.yml | 2 +- cmake/Modules/Packaging.cmake | 2 +- docs/manual/GettingStartedGuide/helloworld.rst | 15 +++++++-------- examples/helloworld/CMakeLists.export | 8 +++----- examples/roundtrip/CMakeLists.export | 8 +++----- examples/throughput/CMakeLists.export | 8 +++----- src/idlc/CMakeLists.txt | 6 +++--- 9 files changed, 34 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index e25c289..3db66a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -191,11 +191,12 @@ before_script: # code has been vetted, the test has been run a great many times (with the odd # failure), and so we now simply skip the test to avoid the spurious failures. script: + - INSTALLPREFIX="$(pwd)/install" - mkdir build - cd build - conan install -b missing -s arch=${ARCH} -s build_type=${BUILD_TYPE} .. - cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX=$(pwd)/install + -DCMAKE_INSTALL_PREFIX=${INSTALLPREFIX} -DUSE_SANITIZER=${ASAN} -DENABLE_SSL=${SSL} -DBUILD_TESTING=on @@ -217,12 +218,15 @@ script: CMAKE_LINKER_FLAGS="-DCMAKE_LINKER_FLAGS=-fsanitize=${USE_SANITIZER}"; CMAKE_C_FLAGS="-DCMAKE_C_FLAGS=-fsanitize=${USE_SANITIZER}"; fi - - mkdir install/share/CycloneDDS/examples/helloworld/build - - cd install/share/CycloneDDS/examples/helloworld/build - - cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} + - cd .. + - mkdir helloworld_build + - cd helloworld_build + - cmake -DCMAKE_PREFIX_PATH=${INSTALLPREFIX} + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${CMAKE_C_FLAGS} ${CMAKE_LINKER_FLAGS} - -G "${GENERATOR}" .. + -G "${GENERATOR}" + ${INSTALLPREFIX}/share/CycloneDDS/examples/helloworld - cmake --build . --config ${BUILD_TYPE} - cd "${TRAVIS_BUILD_DIR}/build" diff --git a/README.md b/README.md index 959743d..2c80530 100644 --- a/README.md +++ b/README.md @@ -124,11 +124,10 @@ We will show you how to build and run an example program that measures latency. built automatically when you build Cyclone DDS, so you don't need to follow these steps to be able to run the program, it is merely to illustrate the process. - $ cd cyclonedds/examples/roundtrip - $ mkdir build - $ cd build - $ cmake .. - $ make + $ mkdir roundtrip + $ cd roundtrip + $ cmake /share/CycloneDDS/examples/helloworld + $ cmake --build . On one terminal start the application that will be responding to pings: diff --git a/appveyor.yml b/appveyor.yml index 5bf38d1..f686920 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -41,7 +41,7 @@ build_script: - cd install/share/CycloneDDS/examples/helloworld - mkdir build - cd build - - cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%GENERATOR%" .. + - cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_PREFIX_PATH=%CD%/../../../../.. -G "%GENERATOR%" .. - cmake --build . --config %CONFIGURATION% -- /nologo /verbosity:minimal /maxcpucount /p:CL_MPCount=2 - cd ../../../../../.. diff --git a/cmake/Modules/Packaging.cmake b/cmake/Modules/Packaging.cmake index a635869..bbc59f2 100644 --- a/cmake/Modules/Packaging.cmake +++ b/cmake/Modules/Packaging.cmake @@ -18,7 +18,7 @@ include(CMakePackageConfigHelpers) include(GNUInstallDirs) set(PACKAGING_MODULE_DIR "${PROJECT_SOURCE_DIR}/cmake/Modules/Packaging") -set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}") +set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") # Generates Config.cmake. configure_package_config_file( diff --git a/docs/manual/GettingStartedGuide/helloworld.rst b/docs/manual/GettingStartedGuide/helloworld.rst index c2c7862..0494952 100644 --- a/docs/manual/GettingStartedGuide/helloworld.rst +++ b/docs/manual/GettingStartedGuide/helloworld.rst @@ -206,13 +206,12 @@ look in the default locations for the code:`CycloneDDS` package. .. _`IdlcGenerate`: -The :code:`CycloneDDS` package provides the :code:`ddsc` library -that contains the DDS API that the application needs. But apart -from that, it also contains helper functionality -(:code:`idlc_generate`) to generate library targets from IDL -files. These library targets can be easily used when compiling -an application that depends on a data type described -in an IDL file. +The :code:`CycloneDDS` package provides the :code:`ddsc` library that +contains the DDS API that the application needs. It also provides a +component "idlc" that provides helper functionality for generating +library targets from IDL files (:code:`idlc_generate`). These library +targets can be easily used when compiling an application that depends on +a data type described in an IDL file. Two applications will be created, :code:`HelloworldPublisher` and :code:`HelloworldSubscriber`. Both consist only out of one @@ -241,7 +240,7 @@ Here, we can let CMake configure the build environment for us by typing: :: - cmake ../ + cmake .. .. note:: CMake does a pretty good job at guessing which generator to use, but some diff --git a/examples/helloworld/CMakeLists.export b/examples/helloworld/CMakeLists.export index 3e24d44..9ecb402 100644 --- a/examples/helloworld/CMakeLists.export +++ b/examples/helloworld/CMakeLists.export @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.5) -if (NOT TARGET CycloneDDS::ddsc) - # Find the CycloneDDS package. If it is not in a default location, try - # finding it relative to the example where it most likely resides. - find_package(CycloneDDS REQUIRED COMPONENTS idlc PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../../") -endif() +# Find the CycloneDDS package. If it is not in a default location, try +# finding it relative to the example where it most likely resides. +find_package(CycloneDDS REQUIRED COMPONENTS idlc PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../../../..") # This is a convenience function, provided by the CycloneDDS package, # that will supply a library target related the the given idl file. diff --git a/examples/roundtrip/CMakeLists.export b/examples/roundtrip/CMakeLists.export index a95a615..845ff71 100644 --- a/examples/roundtrip/CMakeLists.export +++ b/examples/roundtrip/CMakeLists.export @@ -11,11 +11,9 @@ # cmake_minimum_required(VERSION 3.5) -if (NOT TARGET CycloneDDS::ddsc) - # Find the CycloneDDS package. If it is not in a default location, try - # finding it relative to the example where it most likely resides. - find_package(CycloneDDS REQUIRED COMPONENTS idlc PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../../") -endif() +# Find the CycloneDDS package. If it is not in a default location, try +# finding it relative to the example where it most likely resides. +find_package(CycloneDDS REQUIRED COMPONENTS idlc PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../../../..") # This is a convenience function, provided by the CycloneDDS package, # that will supply a library target related the the given idl file. diff --git a/examples/throughput/CMakeLists.export b/examples/throughput/CMakeLists.export index b037bf6..3741a82 100644 --- a/examples/throughput/CMakeLists.export +++ b/examples/throughput/CMakeLists.export @@ -11,11 +11,9 @@ # cmake_minimum_required(VERSION 3.5) -if (NOT TARGET CycloneDDS::ddsc) - # Find the CycloneDDS package. If it is not in a default location, try - # finding it relative to the example where it most likely resides. - find_package(CycloneDDS REQUIRED COMPONENTS idlc PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../../") -endif() +# Find the CycloneDDS package. If it is not in a default location, try +# finding it relative to the example where it most likely resides. +find_package(CycloneDDS REQUIRED COMPONENTS idlc PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../../../..") # This is a convenience function, provided by the CycloneDDS package, # that will supply a library target related the the given idl file. diff --git a/src/idlc/CMakeLists.txt b/src/idlc/CMakeLists.txt index ae210c3..a6b2ea2 100644 --- a/src/idlc/CMakeLists.txt +++ b/src/idlc/CMakeLists.txt @@ -45,17 +45,17 @@ include(cmake/IdlcGenerate.cmake) install( FILES "cmake/IdlcGenerate.cmake" - DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/idlc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/idlc" COMPONENT idlc) install( FILES "${IDLC_SCRIPT_IN}" - DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/idlc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/idlc" COMPONENT idlc) install( FILES "${IDLC_JAR}" - DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/idlc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/idlc" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT idlc)