build: add enable_static_analysis build option
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		
							parent
							
								
									f2c692a118
								
							
						
					
					
						commit
						0a1215d43f
					
				
					 4 changed files with 24 additions and 0 deletions
				
			
		|  | @ -4,6 +4,12 @@ set(CMAKE_CXX_STANDARD 23) | |||
| 
 | ||||
| include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/macros.cmake) | ||||
| 
 | ||||
| add_option(ENABLE_STATIC_ANALYSIS "Enables clang-tidy static analysis") | ||||
| 
 | ||||
| if (ENABLE_STATIC_ANALYSIS) | ||||
|     set(CMAKE_CXX_CLANG_TIDY "clang-tidy;--warnings-as-errors=*;--allow-no-checks") | ||||
| endif () | ||||
| 
 | ||||
| if(WIN32) | ||||
|   add_compile_definitions(LIGHT_PLATFORM_WINDOWS) | ||||
| elseif(UNIX) | ||||
|  |  | |||
|  | @ -11,9 +11,11 @@ class LightRecipe(ConanFile): | |||
|     generators = "CMakeDeps" | ||||
| 
 | ||||
|     options = { | ||||
|         "enable_static_analysis": [True, False], | ||||
|     } | ||||
| 
 | ||||
|     default_options = { | ||||
|         "enable_static_analysis": False, | ||||
|     } | ||||
| 
 | ||||
|     def requirements(self): | ||||
|  | @ -36,7 +38,9 @@ class LightRecipe(ConanFile): | |||
|         tc = CMakeToolchain(self) | ||||
| 
 | ||||
|         tc.variables["CMAKE_BUILD_TYPE"] = self.settings.build_type | ||||
| 
 | ||||
|         tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True | ||||
|         tc.cache_variables["ENABLE_STATIC_ANALYSIS"] = self.options.enable_static_analysis | ||||
| 
 | ||||
|         repo = git.Repo(search_parent_directories=True) | ||||
|         tc.cache_variables["GIT_HASH"] = repo.head.object.hexsha | ||||
|  |  | |||
							
								
								
									
										3
									
								
								external/.clang-tidy
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								external/.clang-tidy
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | |||
| # Disable all checks in this subdirectory | ||||
| Checks: '-*' | ||||
| 
 | ||||
|  | @ -39,3 +39,14 @@ macro (add_executable_module exename) | |||
|     target_include_directories(${exename} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||||
|     target_link_libraries(${exename} PUBLIC base) | ||||
| endmacro () | ||||
| 
 | ||||
| macro (add_option option help) | ||||
|     option(${option} ${help}) | ||||
| 
 | ||||
|     if (${option}) | ||||
|         message(STATUS "${option}: ON") | ||||
|         add_compile_definitions(${option}=1) | ||||
|     else () | ||||
|         message(STATUS "${option}: OFF") | ||||
|     endif () | ||||
| endmacro () | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue