浏览代码

Improved disabling auto detection

Christophe Riccio 7 年之前
父节点
当前提交
de4dbc5662
共有 5 个文件被更改,包括 36 次插入3 次删除
  1. 6 0
      CMakeLists.txt
  2. 3 1
      glm/detail/setup.hpp
  3. 3 1
      glm/simd/platform.h
  4. 12 0
      manual.md
  5. 12 1
      test/core/core_setup_platform_unknown.cpp

+ 6 - 0
CMakeLists.txt

@@ -58,6 +58,12 @@ endif()
 
 option(GLM_TEST_ENABLE_LANG_EXTENSIONS "Enable language extensions" OFF)
 
+option(GLM_DISABLE_AUTO_DETECTION "Enable language extensions" OFF)
+
+if(GLM_DISABLE_AUTO_DETECTION)
+	add_definitions(-DGLM_FORCE_PLATFORM_UNKNOWN -DGLM_FORCE_COMPILER_UNKNOWN -DGLM_FORCE_ARCH_UNKNOWN -DGLM_FORCE_CXX_UNKNOWN)
+endif()
+
 if(GLM_TEST_ENABLE_LANG_EXTENSIONS)
 	set(CMAKE_CXX_EXTENSIONS ON)
 	if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU"))

+ 3 - 1
glm/detail/setup.hpp

@@ -80,7 +80,9 @@
 #	define GLM_LANG_EXT 0
 #endif
 
-#if defined(GLM_FORCE_CXX2A)
+#if (defined(GLM_FORCE_CXX_UNKNOWN))
+#	define GLM_LANG 0
+#elif defined(GLM_FORCE_CXX2A)
 #	define GLM_LANG (GLM_LANG_CXX2A | GLM_LANG_EXT)
 #	define GLM_LANG_STL11_FORCED
 #elif defined(GLM_FORCE_CXX17)

+ 3 - 1
glm/simd/platform.h

@@ -251,7 +251,9 @@
 #define GLM_ARCH_MIPS		(GLM_ARCH_MIPS_BIT)
 #define GLM_ARCH_PPC		(GLM_ARCH_PPC_BIT)
 
-#if defined(GLM_FORCE_PURE) || defined(GLM_FORCE_XYZW_ONLY)
+#ifdef GLM_FORCE_ARCH_UNKNOWN
+#	define GLM_ARCH GLM_ARCH_UNKNOWN
+#elif defined(GLM_FORCE_PURE) || defined(GLM_FORCE_XYZW_ONLY)
 #	if defined(__x86_64__) || defined(_M_X64) || defined(_M_IX86) || defined(__i386__)
 #		define GLM_ARCH (GLM_ARCH_X86)
 #	elif defined(__arm__ ) || defined(_M_ARM)

+ 12 - 0
manual.md

@@ -293,6 +293,18 @@ The following subsections describe each configurations and defines.
 
 TODO
 
+### <a name="section2_3"></a> 2.3. GLM\_FORCE\_COMPILER\_UNKNOWN: Force GLM to no detect the build compiler
+
+TODO
+
+### <a name="section2_4"></a> 2.4. GLM\_FORCE\_ARCH\_UNKNOWN: Force GLM to no detect the build architecture
+
+TODO
+
+### <a name="section2_5"></a> 2.5. GLM\_FORCE\_CXX\_UNKNOWN: Force GLM to no detect the C++ standard
+
+TODO
+
 ### <a name="section2_3"></a> 2.3. GLM\_FORCE\_CXX**: C++ language detection
 
 GLM will automatically take advantage of compilers’ language extensions when enabled. To increase cross platform compatibility and to avoid compiler extensions, a programmer can define GLM\_FORCE\_CXX98 before

+ 12 - 1
test/core/core_setup_platform_unknown.cpp

@@ -1,4 +1,15 @@
-#define GLM_FORCE_PLATFORM_UNKNOWN
+#ifndef GLM_FORCE_PLATFORM_UNKNOWN
+#	define GLM_FORCE_PLATFORM_UNKNOWN
+#endif
+#ifndef GLM_FORCE_COMPILER_UNKNOWN
+#	define GLM_FORCE_COMPILER_UNKNOWN
+#endif
+#ifndef GLM_FORCE_ARCH_UNKNOWN
+#	define GLM_FORCE_ARCH_UNKNOWN
+#endif
+#ifndef GLM_FORCE_CXX_UNKNOWN
+#	define GLM_FORCE_CXX_UNKNOWN
+#endif
 #include <glm/glm.hpp>
 #include <glm/ext.hpp>