From 3bf3bebb6af8cdfe2a5b746a79b4fecf37a772c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Mon, 13 Dec 2021 10:16:08 -0400 Subject: [PATCH] build: export config to local build (#322) --- .github/workflows/ci-test-package-cmake.yml | 19 +++++++++++++++++-- src/CMakeLists.txt | 9 ++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-test-package-cmake.yml b/.github/workflows/ci-test-package-cmake.yml index 955014db..71de1c31 100644 --- a/.github/workflows/ci-test-package-cmake.yml +++ b/.github/workflows/ci-test-package-cmake.yml @@ -189,7 +189,22 @@ jobs: run: | mkdir -p test_package/build/${{ matrix.build_type }} && cd test_package/build/${{ matrix.build_type }} conan install ../../.. - - name: Build test_package CMake + - name: Build test_package CMake (local build) + if: matrix.config.compiler.type == 'VISUAL' + shell: cmd + working-directory: test_package/build/${{ matrix.build_type }} + run: | + call conanvcvars.bat + cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -Dmp-units_DIR=${{ github.workspace }}/build/${{ matrix.build_type }} + cmake --build . + - name: Build test_package CMake (local build) + if: matrix.config.compiler.type != 'VISUAL' + shell: bash + working-directory: test_package/build/${{ matrix.build_type }} + run: | + cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -Dmp-units_DIR=${{ github.workspace }}/build/${{ matrix.build_type }} + cmake --build . + - name: Build test_package CMake (installation) if: matrix.config.compiler.type == 'VISUAL' shell: cmd working-directory: test_package/build/${{ matrix.build_type }} @@ -197,7 +212,7 @@ jobs: call conanvcvars.bat cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_INSTALL_PREFIX=../../../build/${{ matrix.build_type }}/test_package cmake --build . - - name: Build test_package CMake + - name: Build test_package CMake (installation) if: matrix.config.compiler.type != 'VISUAL' shell: bash working-directory: test_package/build/${{ matrix.build_type }} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1373ba3e..02545a22 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,15 +56,18 @@ target_link_libraries(mp-units INTERFACE add_library(mp-units::mp-units ALIAS mp-units) install(TARGETS mp-units EXPORT mp-unitsTargets) +# local build +export(EXPORT mp-unitsTargets NAMESPACE mp-units::) +configure_file("mp-unitsConfig.cmake" "." COPYONLY) +include(CMakePackageConfigHelpers) +write_basic_package_version_file(mp-unitsConfigVersion.cmake COMPATIBILITY SameMajorVersion) + # installation install(EXPORT mp-unitsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mp-units NAMESPACE mp-units:: ) -include(CMakePackageConfigHelpers) -write_basic_package_version_file(mp-unitsConfigVersion.cmake COMPATIBILITY SameMajorVersion) - install(FILES mp-unitsConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/mp-unitsConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mp-units )