Browse Source

Nothing important

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
d4d26890bc
2 changed files with 58 additions and 25 deletions
  1. 15 0
      .editorconfig
  2. 43 25
      CMakeLists.txt

+ 15 - 0
.editorconfig

@@ -0,0 +1,15 @@
+# top-most EditorConfig file
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+indent_style = tab
+indent_size = 4
+
+[*.py]
+indent_style = space
+
+[*.md]
+trim_trailing_whitespace = false

+ 43 - 25
CMakeLists.txt

@@ -159,54 +159,52 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
 endif()
 endif()
 
 
 ################################################################################
 ################################################################################
-# Compiler & linker flags                                                      #
+# Common compiler & linker flags                                               #
 ################################################################################
 ################################################################################
 
 
 if(MINGW)
 if(MINGW)
-	set(COMPILER_FLAGS "${COMPILER_FLAGS} -mconsole ")
+	add_compile_options(-mconsole)
 endif()
 endif()
 
 
-add_definitions(-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
-add_definitions(-DANKI_BUILD)
-
-# ImGUI
-add_definitions(-DIMGUI_USER_CONFIG=<AnKi/Ui/ImGuiConfig.h>)
+add_definitions(
+	-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
+	-DANKI_BUILD
+	-DIMGUI_USER_CONFIG=<AnKi/Ui/ImGuiConfig.h>)
 
 
 if(NOT MSVC)
 if(NOT MSVC)
 	# When building AnKi define this special flag
 	# When building AnKi define this special flag
-	add_definitions("-fPIC")
-
-	add_definitions("-fno-exceptions")
+	add_compile_options(-fPIC -fno-exceptions)
 
 
 	if(GCC AND NOT CLANG)
 	if(GCC AND NOT CLANG)
-		add_definitions("-static-libstdc++")
+		add_compile_options(-static-libstdc++)
 	endif()
 	endif()
 
 
 	if(X86)
 	if(X86)
-		add_definitions("-msse4")
+		add_compile_options(-msse4)
 	endif()
 	endif()
 
 
 	if(ANKI_LTO)
 	if(ANKI_LTO)
-		add_definitions("-flto ")
+		add_compile_options(-flto)
 		set(LINKER_FLAGS "${LINKER_FLAGS} -flto ")
 		set(LINKER_FLAGS "${LINKER_FLAGS} -flto ")
 	endif()
 	endif()
 
 
 	if(ANKI_STRIP)
 	if(ANKI_STRIP)
 		set(LINKER_FLAGS "${LINKER_FLAGS} -s ")
 		set(LINKER_FLAGS "${LINKER_FLAGS} -s ")
-		add_definitions("-s")
+		add_compile_options(-s)
 	endif()
 	endif()
 
 
 	if(ANKI_ADDRESS_SANITIZER)
 	if(ANKI_ADDRESS_SANITIZER)
-		add_definitions("-fsanitize=address ")
+		add_compile_options(-fsanitize=address)
 	endif()
 	endif()
 
 
 	if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
 	if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
-		add_definitions("-O3 -DNDEBUG")
+		add_compile_options(-O3)
+		add_definitions(-DNDEBUG)
 	elseif(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
 	elseif(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
-		add_definitions("-O3 -g3 -fno-omit-frame-pointer")
+		add_compile_options(-O3 -g3 -fno-omit-frame-pointer)
 		set(LINKER_FLAGS "${LINKER_FLAGS} -rdynamic ") # For backtrace()
 		set(LINKER_FLAGS "${LINKER_FLAGS} -rdynamic ") # For backtrace()
 	elseif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
 	elseif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
-		add_definitions("-O0 -g3")
+		add_compile_options(-O0 -g3)
 		set(LINKER_FLAGS "${LINKER_FLAGS} -rdynamic ") # For backtrace()
 		set(LINKER_FLAGS "${LINKER_FLAGS} -rdynamic ") # For backtrace()
 	else()
 	else()
 		message(FATAL_ERROR "Wrong CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
 		message(FATAL_ERROR "Wrong CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
@@ -216,14 +214,18 @@ if(NOT MSVC)
 	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
 	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
 else()
 else()
 	#ProcessorCount(PC)
 	#ProcessorCount(PC)
-	add_compile_options("/MP")
+	add_compile_options(/MP)
 
 
 	if(${CMAKE_BUILD_TYPE} STREQUAL "Release" OR ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
 	if(${CMAKE_BUILD_TYPE} STREQUAL "Release" OR ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
-		#add_definitions("/Ox")
+		#add_definitions(/Ox)
 	endif()
 	endif()
 
 
+	add_definitions(
+		-D_CRT_SECURE_NO_WARNINGS=1 # Disable some string function warnings
+		-D_ITERATOR_DEBUG_LEVEL=0)
+
 	# Full paths in compiler diagnostics else you can't click on visual studio have it open the file+line
 	# Full paths in compiler diagnostics else you can't click on visual studio have it open the file+line
-	add_compile_options("/FC")
+	add_compile_options(/FC)
 endif()
 endif()
 
 
 # Use LLD or gold linker
 # Use LLD or gold linker
@@ -254,6 +256,7 @@ option(BUILD_BULLET3 OFF)
 option(BUILD_CPU_DEMOS OFF)
 option(BUILD_CPU_DEMOS OFF)
 option(BUILD_OPENGL3_DEMOS OFF)
 option(BUILD_OPENGL3_DEMOS OFF)
 option(BUILD_EXTRAS OFF)
 option(BUILD_EXTRAS OFF)
+option(BUILD_UNIT_TESTS OFF)
 
 
 if((LINUX OR MACOS OR WINDOWS) AND GL)
 if((LINUX OR MACOS OR WINDOWS) AND GL)
 	set(ANKI_EXTERN_SUB_DIRS ${ANKI_EXTERN_SUB_DIRS} GLEW)
 	set(ANKI_EXTERN_SUB_DIRS ${ANKI_EXTERN_SUB_DIRS} GLEW)
@@ -404,15 +407,30 @@ endif()
 
 
 # AnKi compiler flags (Mainly warnings)
 # AnKi compiler flags (Mainly warnings)
 if(NOT MSVC)
 if(NOT MSVC)
-	add_definitions(-pedantic -Wno-unknown-warning-option -Wall -W -Wextra -Wstrict-aliasing -Wwrite-strings -Wunused
-		-Wundef -Wno-ignored-attributes -Wno-implicit-fallthrough -Wunused-result
-		-Wconversion -Wno-sign-conversion -Wno-keyword-macro -Wno-string-conversion -Wno-class-memaccess
+	add_compile_options(
+		-pedantic
+		-Wno-unknown-warning-option
+		-Wall
+		-W
+		-Wextra
+		-Wstrict-aliasing
+		-Wwrite-strings
+		-Wunused
+		-Wundef
+		-Wno-ignored-attributes
+		-Wno-implicit-fallthrough
+		-Wunused-result
+		-Wconversion
+		-Wno-sign-conversion
+		-Wno-keyword-macro
+		-Wno-string-conversion
+		-Wno-class-memaccess
 		-Wunused-variable)
 		-Wunused-variable)
 
 
 	set(CMAKE_CXX_STANDARD 17)
 	set(CMAKE_CXX_STANDARD 17)
 else()
 else()
 	#add_definitions("/wd4996 /wd4244 /wd4262 /wd4267 /wd26495 /wd26439")
 	#add_definitions("/wd4996 /wd4244 /wd4262 /wd4267 /wd26495 /wd26439")
-	add_compile_definitions("_CRT_SECURE_NO_WARNINGS=1") # Disable some string function warnings
+	add_compile_options("/std:c++17")
 endif()
 endif()
 
 
 # Add AnKi sub libraries
 # Add AnKi sub libraries