2025-09-21 14:29:19 +03:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								add_option(ENABLE_UNIT_TESTS "Enables the building of the unit test modules")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								add_option(ENABLE_FUZZ_TESTS "Enables the building of the fuzz test modules")
							 | 
						
					
						
							
								
									
										
										
										
											2025-10-16 14:12:26 +03:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								add_option(ENABLE_STATIC_ANALYSIS
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								           "Makes the clang-tidy checks mandatory for compilation")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								add_option(ENABLE_LLVM_COVERAGE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								           "Enables the code coverage instrumentation for clang")
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 14:29:19 +03:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2025-10-16 14:12:26 +03:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if(ENABLE_STATIC_ANALYSIS)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    set(CMAKE_CXX_CLANG_TIDY
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "clang-tidy;--warnings-as-errors=*;--allow-no-checks")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								endif()
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 14:29:19 +03:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								if(ENABLE_LLVM_COVERAGE)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    include(CheckCXXSourceCompiles)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2025-10-16 14:12:26 +03:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        message(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            FATAL_ERROR "ENABLE_LLVM_COVERAGE only supports the clang compiler")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    endif()
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 14:29:19 +03:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # Check for libc++
							 | 
						
					
						
							
								
									
										
										
										
											2025-10-16 14:12:26 +03:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    check_cxx_source_compiles(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 14:29:19 +03:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        #include <string>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        #ifdef _LIBCPP_VERSION
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        int main() { return 0; }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        #else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        #error Not using libc++
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        #endif
							 | 
						
					
						
							
								
									
										
										
										
											2025-10-16 14:12:26 +03:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    "
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        USING_LIBCXX)
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 14:29:19 +03:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if(NOT USING_LIBCXX)
							 | 
						
					
						
							
								
									
										
										
										
											2025-10-16 14:12:26 +03:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        message(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            FATAL_ERROR
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                "ENABLE_LLVM_COVERAGE requires libc++, please compile with -stdlib=libc++"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        )
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 14:29:19 +03:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    endif()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    add_link_options(-fprofile-instr-generate -fcoverage-mapping)
							 | 
						
					
						
							
								
									
										
										
										
											2025-10-16 14:12:26 +03:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								endif()
							 |