Browse Source

Only enable compiler warnings and warnings as error on unit tests

Christophe 1 year ago
parent
commit
7b53739128
3 changed files with 44 additions and 43 deletions
  1. 0 43
      CMakeLists.txt
  2. 3 0
      readme.md
  3. 41 0
      test/CMakeLists.txt

+ 0 - 43
CMakeLists.txt

@@ -244,49 +244,6 @@ elseif(GLM_ENABLE_SIMD_SSE2)
 	message(STATUS "GLM: SSE2 instruction set")
 	message(STATUS "GLM: SSE2 instruction set")
 endif()
 endif()
 
 
-# Compiler and default options
-
-if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-	if(NOT GLM_QUIET)
-		message("GLM: Clang - ${CMAKE_CXX_COMPILER_ID} compiler")
-	endif()
-
-	if(NOT GLM_DISABLE_AUTO_DETECTION)
-		add_compile_options(-Werror -Weverything)
-	endif()
-#	add_compile_options(-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c++11-long-long -Wno-padded -Wno-gnu-anonymous-struct -Wno-nested-anon-types)
-#	add_compile_options(-Wno-undefined-reinterpret-cast -Wno-sign-conversion -Wno-unused-variable -Wno-missing-prototypes -Wno-unreachable-code -Wno-missing-variable-declarations -Wno-sign-compare -Wno-global-constructors -Wno-unused-macros -Wno-format-nonliteral -Wno-float-equal)
-
-elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
-	if(NOT GLM_QUIET)
-		message("GLM: GCC - ${CMAKE_CXX_COMPILER_ID} compiler")
-	endif()
-
-	if(NOT GLM_DISABLE_AUTO_DETECTION)
-		add_compile_options(-Werror)
-#		add_compile_options(-Wpedantic)
-#		add_compile_options(-Wall)
-#		add_compile_options(-Wextra)
-	endif()
-	add_compile_options(-O2)
-	#add_compile_options(-Wno-long-long)
-elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
-	if(NOT GLM_QUIET)
-		message("GLM: Intel - ${CMAKE_CXX_COMPILER_ID} compiler")
-	endif()
-
-elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
-	if(NOT GLM_QUIET)
-		message("GLM: Visual C++ - ${CMAKE_CXX_COMPILER_ID} compiler")
-	endif()
-
-	if(NOT GLM_DISABLE_AUTO_DETECTION)
-		add_compile_options(/W4 /WX)
-	endif()
-#	add_compile_options(/wd4309 /wd4324 /wd4389 /wd4127 /wd4267 /wd4146 /wd4201 /wd4464 /wd4514 /wd4701 /wd4820 /wd4365)
-	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
-endif()
-
 add_subdirectory(glm)
 add_subdirectory(glm)
 
 
 if (GLM_BUILD_TESTS)
 if (GLM_BUILD_TESTS)

+ 3 - 0
readme.md

@@ -107,6 +107,9 @@ target_link_libraries(main PRIVATE glm::glm)
 
 
 ### [GLM 1.0.1](https://github.com/g-truc/glm) - 2024-XX-XX
 ### [GLM 1.0.1](https://github.com/g-truc/glm) - 2024-XX-XX
 
 
+#### Improvements:
+- Enables only warnings as errors while building unit tests
+
 #### Fixes:
 #### Fixes:
 - Fixed C++ language auto detection build, disable C++98 warnings with Clang #1235, #1231
 - Fixed C++ language auto detection build, disable C++98 warnings with Clang #1235, #1231
 - Fixed `GTX_color_space` missing <glm/ext/scalar_constants.hpp> include #1233 #1238
 - Fixed `GTX_color_space` missing <glm/ext/scalar_constants.hpp> include #1233 #1238

+ 41 - 0
test/CMakeLists.txt

@@ -3,6 +3,47 @@ option(GLM_QUIET "No CMake Message" OFF)
 option(GLM_TEST_ENABLE "Build unit tests" ON)
 option(GLM_TEST_ENABLE "Build unit tests" ON)
 option(GLM_PERF_TEST_ENABLE "Build perf tests" OFF)
 option(GLM_PERF_TEST_ENABLE "Build perf tests" OFF)
 
 
+# Compiler and default options
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+	if(NOT GLM_QUIET)
+		message("GLM: Clang - ${CMAKE_CXX_COMPILER_ID} compiler")
+	endif()
+
+	if(NOT GLM_DISABLE_AUTO_DETECTION)
+		add_compile_options(-Werror -Weverything)
+	endif()
+
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+	if(NOT GLM_QUIET)
+		message("GLM: GCC - ${CMAKE_CXX_COMPILER_ID} compiler")
+	endif()
+
+	if(NOT GLM_DISABLE_AUTO_DETECTION)
+		add_compile_options(-Werror)
+#		add_compile_options(-Wpedantic)
+#		add_compile_options(-Wall)
+#		add_compile_options(-Wextra)
+	endif()
+	add_compile_options(-O2)
+	#add_compile_options(-Wno-long-long)
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
+	if(NOT GLM_QUIET)
+		message("GLM: Intel - ${CMAKE_CXX_COMPILER_ID} compiler")
+	endif()
+
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+	if(NOT GLM_QUIET)
+		message("GLM: Visual C++ - ${CMAKE_CXX_COMPILER_ID} compiler")
+	endif()
+
+	if(NOT GLM_DISABLE_AUTO_DETECTION)
+		add_compile_options(/W4 /WX)
+	endif()
+#	add_compile_options(/wd4309 /wd4324 /wd4389 /wd4127 /wd4267 /wd4146 /wd4201 /wd4464 /wd4514 /wd4701 /wd4820 /wd4365)
+	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+endif()
+
 function(glmCreateTestGTC NAME)
 function(glmCreateTestGTC NAME)
 	set(SAMPLE_NAME test-${NAME})
 	set(SAMPLE_NAME test-${NAME})
 	add_executable(${SAMPLE_NAME} ${NAME}.cpp)
 	add_executable(${SAMPLE_NAME} ${NAME}.cpp)