mirror of
				https://github.com/TheLartians/ModernCppStarter.git
				synced 2025-10-31 18:21:35 +01:00 
			
		
		
		
	do it my way, modernize cmake
build dynamic lib use makefile wrapper to test all use cases include clang-tidy config file prevent clang-tidy warnings
This commit is contained in:
		
							parent
							
								
									eedcb6f24e
								
							
						
					
					
						commit
						79060d4af6
					
				
					 10 changed files with 128 additions and 50 deletions
				
			
		|  | @ -1,4 +1,4 @@ | |||
| cmake_minimum_required(VERSION 3.14 FATAL_ERROR) | ||||
| cmake_minimum_required(VERSION 3.14...3.19) | ||||
| 
 | ||||
| project(GreeterStandalone LANGUAGES CXX) | ||||
| 
 | ||||
|  | @ -27,4 +27,8 @@ add_executable(GreeterStandalone ${sources}) | |||
| 
 | ||||
| set_target_properties(GreeterStandalone PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Greeter") | ||||
| 
 | ||||
| target_link_libraries(GreeterStandalone Greeter::Greeter cxxopts) | ||||
| # WORKAROUND for ALIAS target is missing error! CK | ||||
| if(NOT TARGET cxxopts::cxxopts) | ||||
|   add_library(cxxopts::cxxopts ALIAS cxxopts) | ||||
| endif() | ||||
| target_link_libraries(GreeterStandalone Greeter::Greeter cxxopts::cxxopts) | ||||
|  |  | |||
|  | @ -6,15 +6,20 @@ | |||
| #include <string> | ||||
| #include <unordered_map> | ||||
| 
 | ||||
| const std::unordered_map<std::string, greeter::LanguageCode> languages{ | ||||
|     {"en", greeter::LanguageCode::EN}, | ||||
|     {"de", greeter::LanguageCode::DE}, | ||||
|     {"es", greeter::LanguageCode::ES}, | ||||
|     {"fr", greeter::LanguageCode::FR}, | ||||
| }; | ||||
| 
 | ||||
| // NOLINTNEXTLINE(modernize-use-trailing-return-type)
 | ||||
| int main(int argc, char** argv) { | ||||
|   cxxopts::Options options(argv[0], "A program to welcome the world!"); | ||||
|   // prevent warning: initialization of 'languages' with static storage duration may throw an
 | ||||
|   // exception that cannot be caught [cert-err58-cpp]
 | ||||
|   const std::unordered_map<std::string, greeter::LanguageCode> languages{ | ||||
|       {"en", greeter::LanguageCode::EN}, | ||||
|       {"de", greeter::LanguageCode::DE}, | ||||
|       {"es", greeter::LanguageCode::ES}, | ||||
|       {"fr", greeter::LanguageCode::FR}, | ||||
|   }; | ||||
| 
 | ||||
|   // prevent warning: do not use pointer arithmetic
 | ||||
|   // [cppcoreguidelines-pro-bounds-pointer-arithmetic]
 | ||||
|   cxxopts::Options options(*argv, "A program to welcome the world!"); | ||||
| 
 | ||||
|   std::string language; | ||||
|   std::string name; | ||||
|  | @ -33,7 +38,10 @@ int main(int argc, char** argv) { | |||
|   if (result["help"].as<bool>()) { | ||||
|     std::cout << options.help() << std::endl; | ||||
|     return 0; | ||||
|   } else if (result["version"].as<bool>()) { | ||||
|   } | ||||
| 
 | ||||
|   // prevent warning: do not use 'else' after 'return' [readability-else-after-return]
 | ||||
|   if (result["version"].as<bool>()) { | ||||
|     std::cout << "Greeter, version " << GREETER_VERSION << std::endl; | ||||
|     return 0; | ||||
|   } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue