diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7927e4a5a..a8841500d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,9 +21,14 @@ on: branches: - libhal +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: package_and_upload_all_check: uses: libhal/ci/.github/workflows/package_and_upload_all.yml@5.x.y with: modules_support_needed: true + extra_conan_arguments: -o "*:cxx_modules=True" -o "*:freestanding=True" -o "*:contracts=none" -o "*:import_std=False" -o "*:enable_rtti=False" secrets: inherit diff --git a/CMakeLists.txt b/CMakeLists.txt index 9733d5589b..f0e7747f71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ check_cache_var_values(MP_UNITS_DEV_TIME_TRACE NONE ALL MODULES HEADERS) message(STATUS "MP_UNITS_DEV_IWYU: ${MP_UNITS_DEV_IWYU}") message(STATUS "MP_UNITS_DEV_CLANG_TIDY: ${MP_UNITS_DEV_CLANG_TIDY}") message(STATUS "MP_UNITS_DEV_TIME_TRACE: ${MP_UNITS_DEV_TIME_TRACE}") +message(STATUS "MP_UNITS_RTTI: ${MP_UNITS_RTTI}") # make sure that the file is being used as an entry point include(modern_project_structure) diff --git a/conanfile.py b/conanfile.py index de39174c40..794f411736 100644 --- a/conanfile.py +++ b/conanfile.py @@ -61,6 +61,7 @@ class MPUnitsConan(ConanFile): "no_crtp": [True, False], "contracts": ["none", "gsl-lite", "ms-gsl"], "freestanding": [True, False], + "enable_rtti": [True, False], } default_options = { # "cxx_modules" default set in config_options() @@ -70,6 +71,7 @@ class MPUnitsConan(ConanFile): "import_std": False, # still experimental in CMake "contracts": "gsl-lite", "freestanding": False, + "enable_rtti": True, } implements = ["auto_header_only"] exports = "LICENSE.md" @@ -82,6 +84,7 @@ class MPUnitsConan(ConanFile): "CMakeLists.txt", ) no_copy_source = True + user = "libhal" @property def _feature_compatibility(self): @@ -181,7 +184,8 @@ def _run_clang_tidy(self): return bool(self.conf.get("user.mp-units.analyze:clang-tidy", default=False)) def set_version(self): - content = load(self, os.path.join(self.recipe_folder, "src/CMakeLists.txt")) + content = load(self, os.path.join( + self.recipe_folder, "src/CMakeLists.txt")) version = re.search( r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content ).group(1) @@ -282,7 +286,10 @@ def generate(self): else: tc.cache_variables["MP_UNITS_API_STD_FORMAT"] = opt.std_format tc.cache_variables["MP_UNITS_API_NO_CRTP"] = opt.no_crtp - tc.cache_variables["MP_UNITS_API_CONTRACTS"] = str(opt.contracts).upper() + tc.cache_variables["MP_UNITS_API_CONTRACTS"] = str( + opt.contracts).upper() + + tc.cache_variables["MP_UNITS_RTTI"] = opt.enable_rtti tc.generate() deps = CMakeDeps(self) @@ -329,28 +336,34 @@ def package_info(self): "MP_UNITS_API_CONTRACTS=0" ) elif self.options.contracts == "gsl-lite": - self.cpp_info.components["core"].requires.append("gsl-lite::gsl-lite") + self.cpp_info.components["core"].requires.append( + "gsl-lite::gsl-lite") self.cpp_info.components["core"].defines.append( "MP_UNITS_API_CONTRACTS=2" ) elif self.options.contracts == "ms-gsl": - self.cpp_info.components["core"].requires.append("ms-gsl::ms-gsl") + self.cpp_info.components["core"].requires.append( + "ms-gsl::ms-gsl") self.cpp_info.components["core"].defines.append( "MP_UNITS_API_CONTRACTS=3" ) # handle API options self.cpp_info.components["core"].defines.append( - "MP_UNITS_API_NO_CRTP=" + str(int(self.options.no_crtp == True)) + "MP_UNITS_API_NO_CRTP=" + + str(int(self.options.no_crtp == True)) ) # handle hosted configuration if self.options.freestanding: - self.cpp_info.components["core"].defines.append("MP_UNITS_HOSTED=0") + self.cpp_info.components["core"].defines.append( + "MP_UNITS_HOSTED=0") else: - self.cpp_info.components["core"].defines.append("MP_UNITS_HOSTED=1") + self.cpp_info.components["core"].defines.append( + "MP_UNITS_HOSTED=1") if not self.options.std_format: - self.cpp_info.components["core"].requires.append("fmt::fmt") + self.cpp_info.components["core"].requires.append( + "fmt::fmt") self.cpp_info.components["core"].defines.append( "MP_UNITS_API_STD_FORMAT=" + str(int(self.options.std_format == True)) @@ -358,7 +371,8 @@ def package_info(self): # handle import std if self.options.import_std: - self.cpp_info.components["core"].defines.append("MP_UNITS_IMPORT_STD") + self.cpp_info.components["core"].defines.append( + "MP_UNITS_IMPORT_STD") if compiler == "clang" and Version(compiler.version) < 19: self.cpp_info.components["core"].cxxflags.append( "-Wno-deprecated-declarations" @@ -375,4 +389,5 @@ def package_info(self): and Version(compiler.version).major == 20 and Version(compiler.version).minor == 1 ): - self.cpp_info.components["core"].cxxflags.append("-Wno-unused-result") + self.cpp_info.components["core"].cxxflags.append( + "-Wno-unused-result") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bd878c0bae..ccb704f1ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -93,6 +93,7 @@ message(STATUS "MP_UNITS_API_NO_CRTP: ${MP_UNITS_API_NO_CRTP}") message(STATUS "MP_UNITS_API_THROWING_CONSTRAINTS: ${MP_UNITS_API_THROWING_CONSTRAINTS}") message(STATUS "MP_UNITS_API_FREESTANDING: ${MP_UNITS_API_FREESTANDING}") message(STATUS "MP_UNITS_API_CONTRACTS: ${MP_UNITS_API_CONTRACTS}") +message(STATUS "MP_UNITS_RTTI: ${MP_UNITS_RTTI}") # validate options if(MP_UNITS_API_FREESTANDING AND NOT MP_UNITS_API_CONTRACTS STREQUAL "NONE") diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6e266ee0cf..3194230ced 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -176,3 +176,10 @@ if(MP_UNITS_DEV_TIME_TRACE STREQUAL "ALL") elseif(MP_UNITS_DEV_TIME_TRACE STREQUAL "MODULES") target_compile_options(mp-units-core PRIVATE "-ftime-trace") endif() + +# RTTI enable +if(MP_UNITS_RTTI) + target_compile_options(mp-units-core ${MP_UNITS_TARGET_SCOPE} "-frtti") +else() + target_compile_options(mp-units-core ${MP_UNITS_TARGET_SCOPE} "-fno-rtti") +endif()