[Piglit] [PATCH] cmake: Target C99.
Jose Fonseca
jfonseca at vmware.com
Thu Dec 10 03:05:56 PST 2015
GCC 5.x and 4.x have different defaults, so it's better to explicitly
specify the target C standard to keep builds consistent.
---
CMakeLists.txt | 6 ++++++
tests/shaders/shader_runner.c | 4 +---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4df0202..2da1e6f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -224,6 +224,12 @@ if (NOT MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
ENDIF (CXX_COMPILER_FLAG_WALL)
+ # Target C99. GCC's default is gnu11 for 5.0 and newer, gnu89 for
+ # older versions.
+ check_c_compiler_flag ("-std=gnu99" C_COMPILER_FLAG_STD_GNU99)
+ if (C_COMPILER_FLAG_STD_GNU99)
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
+ endif ()
# MSVC does not support C99 variable length arrays
CHECK_C_COMPILER_FLAG("-Werror=vla" C_COMPILER_FLAG_WEVLA)
IF (C_COMPILER_FLAG_WEVLA)
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 12a46de..966abe9 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -973,8 +973,6 @@ leave_state(enum states state, const char *line)
void
process_shader(GLenum target, unsigned num_shaders, GLuint *shaders)
{
- unsigned i;
-
if (num_shaders == 0)
return;
@@ -983,7 +981,7 @@ process_shader(GLenum target, unsigned num_shaders, GLuint *shaders)
glProgramParameteri(prog, GL_PROGRAM_SEPARABLE, GL_TRUE);
}
- for (i = 0; i < num_shaders; i++) {
+ for (unsigned i = 0; i < num_shaders; i++) {
glAttachShader(prog, shaders[i]);
}
--
2.5.0
More information about the Piglit
mailing list