build: add enable_tests compile option
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is failing
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	continuous-integration/drone/push Build is failing
				
			refactor: minor cmake refactor
This commit is contained in:
		
							parent
							
								
									a54885b02e
								
							
						
					
					
						commit
						b25ea41096
					
				
					 6 changed files with 40 additions and 27 deletions
				
			
		|  | @ -2,29 +2,15 @@ cmake_minimum_required(VERSION 3.14) | |||
| project(Light) | ||||
| set(CMAKE_CXX_STANDARD 23) | ||||
| 
 | ||||
| include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/macros.cmake) | ||||
| 
 | ||||
| add_option(ENABLE_STATIC_ANALYSIS "Enables clang-tidy static analysis") | ||||
| include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/functions.cmake) | ||||
| include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/definitions.cmake) | ||||
| include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/dependencies.cmake) | ||||
| 
 | ||||
| add_option(ENABLE_STATIC_ANALYSIS "Performs static analysis via clang-tidy and fails build on failing checks") | ||||
| 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) | ||||
|   add_compile_definitions(LIGHT_PLATFORM_LINUX) | ||||
| endif() | ||||
| 
 | ||||
| find_package(glfw3 REQUIRED) | ||||
| find_package(glm REQUIRED) | ||||
| find_package(spdlog REQUIRED) | ||||
| find_package(stb REQUIRED) | ||||
| find_package(yaml-cpp REQUIRED) | ||||
| find_package(EnTT REQUIRED) | ||||
| find_package(opengl_system REQUIRED) | ||||
| find_package(nlohmann_json REQUIRED) | ||||
| find_package(lz4 REQUIRED) | ||||
| 
 | ||||
| add_option(ENABLE_TESTS "Enables the building of the test modules") | ||||
| add_subdirectory(./modules) | ||||
| add_subdirectory(./external) | ||||
|  |  | |||
|  | @ -11,11 +11,13 @@ class LightRecipe(ConanFile): | |||
|     generators = "CMakeDeps" | ||||
| 
 | ||||
|     options = { | ||||
|         "enable_tests": [True, False], | ||||
|         "enable_static_analysis": [True, False], | ||||
|         "export_compile_commands": [True, False], | ||||
|     } | ||||
| 
 | ||||
|     default_options = { | ||||
|         "enable_tests": True, | ||||
|         "export_compile_commands": True, | ||||
|         "enable_static_analysis": False, | ||||
|     } | ||||
|  | @ -43,6 +45,7 @@ class LightRecipe(ConanFile): | |||
| 
 | ||||
|         tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = self.options.export_compile_commands | ||||
|         tc.cache_variables["ENABLE_STATIC_ANALYSIS"] = self.options.enable_static_analysis | ||||
|         tc.cache_variables["ENABLE_TESTS"] = self.options.enable_tests | ||||
| 
 | ||||
|         repo = git.Repo(search_parent_directories=True) | ||||
|         tc.cache_variables["GIT_HASH"] = repo.head.object.hexsha | ||||
|  |  | |||
							
								
								
									
										6
									
								
								docs/index.rst
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								docs/index.rst
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | |||
| A bleeding-edge, cross-platform, cross-graphics-api, minimal-dependencies modern game-engine. | ||||
| 
 | ||||
| Supported Platforms: Windows, Mac, Linux, FreeBSD | ||||
| Supported GraphicsAPIs: DirectX12-Ultimate, Vulkan 1.4, Metal, OpenGL 4.6 | ||||
| 
 | ||||
| Dependencies: stdlib, meshoptimizer | ||||
							
								
								
									
										5
									
								
								tools/cmake/definitions.cmake
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tools/cmake/definitions.cmake
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | |||
| if(WIN32) | ||||
|   add_compile_definitions(LIGHT_PLATFORM_WINDOWS) | ||||
| elseif(UNIX) | ||||
|   add_compile_definitions(LIGHT_PLATFORM_LINUX) | ||||
| endif() | ||||
							
								
								
									
										9
									
								
								tools/cmake/dependencies.cmake
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								tools/cmake/dependencies.cmake
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | |||
| find_package(glfw3 REQUIRED) | ||||
| find_package(glm REQUIRED) | ||||
| find_package(spdlog REQUIRED) | ||||
| find_package(stb REQUIRED) | ||||
| find_package(yaml-cpp REQUIRED) | ||||
| find_package(EnTT REQUIRED) | ||||
| find_package(opengl_system REQUIRED) | ||||
| find_package(nlohmann_json REQUIRED) | ||||
| find_package(lz4 REQUIRED) | ||||
|  | @ -1,4 +1,4 @@ | |||
| macro (add_library_module libname) | ||||
| function (add_library_module libname) | ||||
|     if ("${ARGN}" STREQUAL "") # Header only library | ||||
|         message("Adding INTERFACE library ${libname}") | ||||
|         add_library(${libname} INTERFACE) | ||||
|  | @ -25,9 +25,9 @@ macro (add_library_module libname) | |||
|             target_link_libraries(${libname} PUBLIC base) | ||||
|         endif () | ||||
|     endif () | ||||
| endmacro () | ||||
| endfunction () | ||||
| 
 | ||||
| macro (add_executable_module exename) | ||||
| function (add_executable_module exename) | ||||
|     set(source_files) | ||||
|     set(source_directory "${CMAKE_CURRENT_SOURCE_DIR}/src") | ||||
|     foreach (source_file ${ARGN}) | ||||
|  | @ -38,9 +38,13 @@ macro (add_executable_module exename) | |||
|     add_executable(${exename} ${source_files}) | ||||
|     target_include_directories(${exename} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||||
|     target_link_libraries(${exename} PRIVATE base) | ||||
| endmacro () | ||||
| endfunction () | ||||
| 
 | ||||
| function (add_test_module exename) | ||||
|     if (NOT ${ENABLE_TESTS}) | ||||
|         return() | ||||
|     endif () | ||||
| 
 | ||||
| macro (add_test_module exename) | ||||
|     set(source_files) | ||||
|     set(source_directory "${CMAKE_CURRENT_SOURCE_DIR}/src") | ||||
|     foreach (source_file ${ARGN}) | ||||
|  | @ -51,9 +55,9 @@ macro (add_test_module exename) | |||
|     add_executable(${exename}_tests ${source_files}) | ||||
|     target_include_directories(${exename} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||||
|     target_link_libraries(${exename}_tests PRIVATE ${exename} base test) | ||||
| endmacro () | ||||
| endfunction () | ||||
| 
 | ||||
| macro (add_option option help) | ||||
| function (add_option option help) | ||||
|     option(${option} ${help}) | ||||
| 
 | ||||
|     if (${option}) | ||||
|  | @ -62,4 +66,4 @@ macro (add_option option help) | |||
|     else () | ||||
|         message(STATUS "${option}: OFF") | ||||
|     endif () | ||||
| endmacro () | ||||
| endfunction () | ||||
		Loading…
	
	Add table
		
		Reference in a new issue