From 8f04bd9cfe40f1a37daaf6c9af54b8520fde411f Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 15 Feb 2021 17:06:09 +0100 Subject: [PATCH] build: `mp::units` CMake target was a bad idea -> `mp-units::mp-units` is back --- conanfile.py | 35 +++++++------------ docs/CHANGELOG.md | 1 - docs/usage.rst | 4 +-- example/CMakeLists.txt | 2 +- example/alternative_namespaces/CMakeLists.txt | 2 +- src/CMakeLists.txt | 3 +- test/unit_test/runtime/CMakeLists.txt | 2 +- test/unit_test/static/CMakeLists.txt | 2 +- test_package/CMakeLists.txt | 2 +- 9 files changed, 21 insertions(+), 32 deletions(-) diff --git a/conanfile.py b/conanfile.py index a2b041ff..eaf5feeb 100644 --- a/conanfile.py +++ b/conanfile.py @@ -67,19 +67,22 @@ class UnitsConan(ConanFile): # } generators = "cmake_paths" + _cmake = None + @property def _run_tests(self): return tools.get_env("CONAN_RUN_TESTS", False) def _configure_cmake(self): - cmake = CMake(self) - if self._run_tests: - # developer's mode (unit tests, examples, documentation, restrictive compilation warnings, ...) - cmake.configure() - else: - # consumer's mode (library sources only) - cmake.configure(source_folder="src") - return cmake + if not self._cmake: + self._cmake = CMake(self) + if self._run_tests: + # developer's mode (unit tests, examples, documentation, restrictive compilation warnings, ...) + self._cmake.configure() + else: + # consumer's mode (library sources only) + self._cmake.configure(source_folder="src") + return self._cmake def validate(self): compiler = self.settings.compiler @@ -132,20 +135,8 @@ class UnitsConan(ConanFile): self.info.header_only() def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "mp-units" - self.cpp_info.filenames["cmake_find_package_multi"] = "mp-units" - self.cpp_info.names["cmake_find_package"] = "mp" - self.cpp_info.names["cmake_find_package_multi"] = "mp" - self.cpp_info.components["units"].name = "units" - self.cpp_info.components["units"].requires = ["fmt::fmt", "gsl-lite::gsl-lite"] - compiler = self.settings.compiler - version = Version(self.settings.compiler.version) if compiler == "gcc": - self.cpp_info.components["units"].cxxflags = [ - "-Wno-non-template-friend" - ] + self.cpp_info.cxxflags = ["-Wno-non-template-friend"] elif compiler == "Visual Studio": - self.cpp_info.components["units"].cxxflags = [ - "/utf-8" - ] + self.cpp_info.cxxflags = ["/utf-8"] diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 925778b5..3e8b05ee 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -17,7 +17,6 @@ - (!) fix: `dim_torque` now properly divides by an angle (instead of multiply) + default unit name change - fix: `quantity_cast()` fixed to work correctly with representation types not convertible from `std::intmax_t` - fix: ambiguous case for empty type list resolved - - (!) build: The library should now be linked as `mp::units` in the CMake's `target_link_libraries()` - (!) build: `BUILD_DOCS` CMake option renamed to `UNITS_BUILD_DOCS` - build: doxygen updated to 1.8.20 - build: catch2 updated to 2.13.4 diff --git a/docs/usage.rst b/docs/usage.rst index bb0541c8..6973adec 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -193,7 +193,7 @@ defined by the library. To do so you should use *CMakeLists.txt* file from the * add_subdirectory(/src) # ... - target_link_libraries( PUBLIC|PRIVATE|INTERFACE mp::units) + target_link_libraries( PUBLIC|PRIVATE|INTERFACE mp-units::mp-units) .. important:: @@ -238,7 +238,7 @@ library release the following steps may be performed: .. code-block:: cmake - target_link_libraries( PUBLIC|PRIVATE|INTERFACE mp::units) + target_link_libraries( PUBLIC|PRIVATE|INTERFACE mp-units::mp-units) target_compile_features( PUBLIC|PRIVATE|INTERFACE cxx_std_20) .. important:: diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 3dd6e1ab..a0729101 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.2) function(add_example target) add_executable(${target} ${target}.cpp) - target_link_libraries(${target} PRIVATE mp::units) + target_link_libraries(${target} PRIVATE mp-units::mp-units) endfunction() add_example(box_example) diff --git a/example/alternative_namespaces/CMakeLists.txt b/example/alternative_namespaces/CMakeLists.txt index 8733f7f6..509795e7 100644 --- a/example/alternative_namespaces/CMakeLists.txt +++ b/example/alternative_namespaces/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.2) function(add_example target) add_executable(${target}_alt ${target}.cpp) - target_link_libraries(${target}_alt PRIVATE mp::units) + target_link_libraries(${target}_alt PRIVATE mp-units::mp-units) endfunction() add_example(box_example) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 74f20975..e3bb0021 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,8 +78,7 @@ if(DEFINED UNITS_DOWNCAST_MODE) endif() endif() -add_library(mp::units ALIAS mp-units) -set_target_properties(mp-units PROPERTIES EXPORT_NAME units) +add_library(mp-units::mp-units ALIAS mp-units) # installation info include(CMakePackageConfigHelpers) diff --git a/test/unit_test/runtime/CMakeLists.txt b/test/unit_test/runtime/CMakeLists.txt index 1d5f6a87..eda86a20 100644 --- a/test/unit_test/runtime/CMakeLists.txt +++ b/test/unit_test/runtime/CMakeLists.txt @@ -34,7 +34,7 @@ add_executable(unit_tests_runtime ) target_link_libraries(unit_tests_runtime PRIVATE - mp::units + mp-units::mp-units Catch2::Catch2 ) diff --git a/test/unit_test/static/CMakeLists.txt b/test/unit_test/static/CMakeLists.txt index d44aa529..a98c54ca 100644 --- a/test/unit_test/static/CMakeLists.txt +++ b/test/unit_test/static/CMakeLists.txt @@ -49,5 +49,5 @@ add_library(unit_tests_static ) target_link_libraries(unit_tests_static PRIVATE - mp::units + mp-units::mp-units ) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 5a5e9986..5b0dc1ae 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -26,4 +26,4 @@ project(test_package) find_package(mp-units CONFIG REQUIRED) add_executable(test_package test_package.cpp) -target_link_libraries(test_package PRIVATE mp::units) +target_link_libraries(test_package PRIVATE mp-units::mp-units)